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", () => {
const config = new TestConfig(false)
beforeEach(async () => {
beforeAll(async () => {
await config.init()
})

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ describe("/webhooks", () => {
afterAll(setup.afterAll)
beforeEach(async () => {
const setupTest = async () => {
config.modeSelf()
await config.init()
const autoConfig = basicAutomation()
@ -19,7 +19,9 @@ describe("/webhooks", () => {
}
await config.createAutomation(autoConfig)
webhook = await config.createWebhook()
})
}
beforeAll(setupTest)
describe("create", () => {
it("should create a webhook successfully", async () => {
@ -85,6 +87,8 @@ describe("/webhooks", () => {
})
describe("build schema", () => {
beforeAll(setupTest)
it("should allow building a schema", async () => {
const res = await request
.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", () => {
let config = setup.getConfig()
beforeEach(async () => {
beforeAll(async () => {
await automation.init()
await config.init()
})

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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