1
0
Fork 0
mirror of synced 2024-10-06 04:54:52 +13:00

Extract test utils

This commit is contained in:
Adria Navarro 2023-07-18 10:26:53 +02:00
parent 7f3de5d40e
commit f7452aa7fa
2 changed files with 15 additions and 9 deletions

View file

@ -35,13 +35,6 @@ describe("/v2/views", () => {
table = await config.createTable(priceTable())
})
const getView = (viewId: string) => {
return request
.get(`/api/v2/views/${viewId}`)
.set(config.defaultHeaders())
.expect("Content-Type", /json/)
}
describe("fetch", () => {
const views: ViewV2[] = []
@ -98,6 +91,13 @@ describe("/v2/views", () => {
})
describe("getView", () => {
const getView = (viewId: string) => {
return request
.get(`/api/v2/views/${viewId}`)
.set(config.defaultHeaders())
.expect("Content-Type", /json/)
}
let view: ViewV2
beforeAll(async () => {
view = await config.createViewV2()
@ -155,14 +155,14 @@ describe("/v2/views", () => {
})
it("can delete an existing view", async () => {
await getView(view._id!).expect(200)
await config.getViewV2(view._id!).expect(200)
await request
.delete(`/api/v2/views/${view._id}`)
.set(config.defaultHeaders())
.expect(204)
await getView(view._id!).expect(404)
await config.getViewV2(view._id!).expect(404)
})
})
})

View file

@ -647,6 +647,12 @@ class TestConfiguration {
return this._req(view, null, controllers.view.v2.save)
}
getViewV2(viewId: string): supertest.Test {
return this.request!.get(`/api/v2/views/${viewId}`)
.set(this.defaultHeaders())
.expect("Content-Type", /json/)
}
// AUTOMATION
async createAutomation(config?: any) {