Replace beforeeach for before alls

This commit is contained in:
adrinr 2023-02-03 19:02:40 +00:00
parent fe8853580e
commit 420cb36ca7
32 changed files with 65 additions and 35 deletions

View File

@ -41,7 +41,7 @@ const datasets = {
describe("Rest Importer", () => { describe("Rest Importer", () => {
const config = new TestConfig(false) const config = new TestConfig(false)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
}) })

View File

@ -10,8 +10,11 @@ describe("/static", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { beforeAll(async () => {
app = await config.init() app = await config.init()
})
beforeEach(()=>{
jest.clearAllMocks() jest.clearAllMocks()
}) })

View File

@ -7,7 +7,7 @@ describe("/api/keys", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
}) })

View File

@ -7,7 +7,7 @@ describe("/authenticate", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
}) })

View File

@ -7,7 +7,7 @@ describe("/component", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
}) })

View File

@ -8,7 +8,7 @@ describe("/dev", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
jest.clearAllMocks() jest.clearAllMocks()
}) })

View File

@ -7,7 +7,7 @@ describe("/integrations", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
}) })

View File

@ -10,7 +10,7 @@ describe("/layouts", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
layout = await config.createLayout() layout = await config.createLayout()
jest.clearAllMocks() jest.clearAllMocks()

View File

@ -9,7 +9,7 @@ describe("/metadata", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
automation = await config.createAutomation() automation = await config.createAutomation()
}) })

View File

@ -7,7 +7,7 @@ describe("run misc tests", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
}) })

View File

@ -30,11 +30,15 @@ describe("/queries", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { const setupTest = async()=>{
config.modeSelf()
await config.init() await config.init()
datasource = await config.createDatasource() datasource = await config.createDatasource()
query = await config.createQuery() query = await config.createQuery()
}
beforeAll(async () => {
await setupTest()
}) })
async function createInvalidIntegration() { async function createInvalidIntegration() {
@ -105,6 +109,10 @@ describe("/queries", () => {
}) })
describe("fetch", () => { describe("fetch", () => {
beforeEach(async() => {
await setupTest()
})
it("returns all the queries from the server", async () => { it("returns all the queries from the server", async () => {
const res = await request const res = await request
.get(`/api/queries`) .get(`/api/queries`)
@ -182,6 +190,10 @@ describe("/queries", () => {
}) })
describe("destroy", () => { describe("destroy", () => {
beforeEach(async() => {
await setupTest()
})
it("deletes a query and returns a success message", async () => { it("deletes a query and returns a success message", async () => {
await request await request
.delete(`/api/queries/${query._id}/${query._rev}`) .delete(`/api/queries/${query._id}/${query._rev}`)
@ -243,6 +255,10 @@ describe("/queries", () => {
}) })
describe("execute", () => { describe("execute", () => {
beforeEach(async() => {
await setupTest()
})
it("should be able to execute the query", async () => { it("should be able to execute the query", async () => {
const res = await request const res = await request
.post(`/api/queries/${query._id}`) .post(`/api/queries/${query._id}`)

View File

@ -10,7 +10,7 @@ describe("/roles", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
}) })
@ -60,6 +60,11 @@ describe("/roles", () => {
}) })
describe("fetch", () => { describe("fetch", () => {
beforeAll(async () => {
// Recreate the app
await config.init()
})
it("should list custom roles, plus 2 default roles", async () => { it("should list custom roles, plus 2 default roles", async () => {
const customRole = await config.createRole() const customRole = await config.createRole()

View File

@ -16,7 +16,7 @@ describe("/routing", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
screen = basicScreen() screen = basicScreen()
screen.routing.route = route screen.routing.route = route

View File

@ -8,7 +8,7 @@ describe("/static", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { beforeAll(async () => {
config.modeSelf() config.modeSelf()
app = await config.init() app = await config.init()
}) })

View File

@ -10,7 +10,7 @@ describe("/tables", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { beforeAll(async () => {
const app = await config.init() const app = await config.init()
appId = app.appId appId = app.appId
}) })

View File

@ -6,7 +6,7 @@ describe("/templates", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
}) })

View File

@ -28,8 +28,11 @@ describe("/views", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
})
beforeEach(async() => {
table = await config.createTable(priceTable()) table = await config.createTable(priceTable())
}) })

View File

@ -9,7 +9,7 @@ describe("/webhooks", () => {
afterAll(setup.afterAll) afterAll(setup.afterAll)
beforeEach(async () => { const setupTest = async () => {
config.modeSelf() config.modeSelf()
await config.init() await config.init()
const autoConfig = basicAutomation() const autoConfig = basicAutomation()
@ -19,7 +19,9 @@ describe("/webhooks", () => {
} }
await config.createAutomation(autoConfig) await config.createAutomation(autoConfig)
webhook = await config.createWebhook() webhook = await config.createWebhook()
}) }
beforeAll(setupTest)
describe("create", () => { describe("create", () => {
it("should create a webhook successfully", async () => { it("should create a webhook successfully", async () => {
@ -85,6 +87,8 @@ describe("/webhooks", () => {
}) })
describe("build schema", () => { describe("build schema", () => {
beforeAll(setupTest)
it("should allow building a schema", async () => { it("should allow building a schema", async () => {
const res = await request const res = await request
.post(`/api/webhooks/schema/${config.getAppId()}/${webhook._id}`) .post(`/api/webhooks/schema/${config.getAppId()}/${webhook._id}`)

View File

@ -21,7 +21,7 @@ const setup = require("./utilities")
describe("Run through some parts of the automations system", () => { describe("Run through some parts of the automations system", () => {
let config = setup.getConfig() let config = setup.getConfig()
beforeEach(async () => { beforeAll(async () => {
await automation.init() await automation.init()
await config.init() await config.init()
}) })

View File

@ -3,7 +3,7 @@ const setup = require("./utilities")
describe("test the bash action", () => { describe("test the bash action", () => {
let config = setup.getConfig() let config = setup.getConfig()
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
}) })
afterAll(setup.afterAll) afterAll(setup.afterAll)

View File

@ -7,7 +7,7 @@ describe("test the outgoing webhook action", () => {
let inputs let inputs
let config = setup.getConfig() let config = setup.getConfig()
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
inputs = { inputs = {
username: "joe_bloggs", username: "joe_bloggs",

View File

@ -1,10 +1,9 @@
const setup = require("./utilities") const setup = require("./utilities")
describe("test the execute query action", () => { describe("test the execute query action", () => {
let datasource
let config = setup.getConfig() let config = setup.getConfig()
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
await config.createDatasource() await config.createDatasource()

View File

@ -3,7 +3,7 @@ const setup = require("./utilities")
describe("test the execute script action", () => { describe("test the execute script action", () => {
let config = setup.getConfig() let config = setup.getConfig()
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
}) })
afterAll(setup.afterAll) afterAll(setup.afterAll)

View File

@ -7,7 +7,7 @@ describe("test the outgoing webhook action", () => {
let inputs let inputs
let config = setup.getConfig() let config = setup.getConfig()
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
inputs = { inputs = {
requestMethod: "POST", requestMethod: "POST",

View File

@ -36,7 +36,7 @@ const setup = require("./utilities")
describe("test the outgoing webhook action", () => { describe("test the outgoing webhook action", () => {
let inputs let inputs
let config = setup.getConfig() let config = setup.getConfig()
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
}) })

View File

@ -3,7 +3,7 @@ const setup = require("./utilities")
describe("test the server log action", () => { describe("test the server log action", () => {
let config = setup.getConfig() let config = setup.getConfig()
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
inputs = { inputs = {
text: "log message", text: "log message",

View File

@ -4,7 +4,7 @@ describe("test the update row action", () => {
let table, row, inputs let table, row, inputs
let config = setup.getConfig() let config = setup.getConfig()
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
table = await config.createTable() table = await config.createTable()
row = await config.createRow() row = await config.createRow()

View File

@ -7,7 +7,7 @@ describe("test the outgoing webhook action", () => {
let inputs let inputs
let config = setup.getConfig() let config = setup.getConfig()
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
inputs = { inputs = {
value1: "test", value1: "test",

View File

@ -9,7 +9,7 @@ describe("test link functionality", () => {
describe("getLinkedTable", () => { describe("getLinkedTable", () => {
let table let table
beforeEach(async () => { beforeAll(async () => {
const app = await config.init() const app = await config.init()
appId = app.appId appId = app.appId
table = await config.createTable() table = await config.createTable()

View File

@ -6,7 +6,7 @@ const migration = require("../appUrls")
describe("run", () => { describe("run", () => {
let config = new TestConfig(false) let config = new TestConfig(false)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
}) })

View File

@ -11,7 +11,7 @@ const migration = require("../syncQuotas")
describe("run", () => { describe("run", () => {
let config = new TestConfig(false) let config = new TestConfig(false)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
}) })

View File

@ -19,7 +19,7 @@ const migration = require("../userEmailViewCasing")
describe("run", () => { describe("run", () => {
let config = new TestConfig(false) let config = new TestConfig(false)
beforeEach(async () => { beforeAll(async () => {
await config.init() await config.init()
}) })