Extract test utils
This commit is contained in:
parent
7f3de5d40e
commit
f7452aa7fa
|
@ -35,13 +35,6 @@ describe("/v2/views", () => {
|
||||||
table = await config.createTable(priceTable())
|
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", () => {
|
describe("fetch", () => {
|
||||||
const views: ViewV2[] = []
|
const views: ViewV2[] = []
|
||||||
|
|
||||||
|
@ -98,6 +91,13 @@ describe("/v2/views", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("getView", () => {
|
describe("getView", () => {
|
||||||
|
const getView = (viewId: string) => {
|
||||||
|
return request
|
||||||
|
.get(`/api/v2/views/${viewId}`)
|
||||||
|
.set(config.defaultHeaders())
|
||||||
|
.expect("Content-Type", /json/)
|
||||||
|
}
|
||||||
|
|
||||||
let view: ViewV2
|
let view: ViewV2
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
view = await config.createViewV2()
|
view = await config.createViewV2()
|
||||||
|
@ -155,14 +155,14 @@ describe("/v2/views", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("can delete an existing view", async () => {
|
it("can delete an existing view", async () => {
|
||||||
await getView(view._id!).expect(200)
|
await config.getViewV2(view._id!).expect(200)
|
||||||
|
|
||||||
await request
|
await request
|
||||||
.delete(`/api/v2/views/${view._id}`)
|
.delete(`/api/v2/views/${view._id}`)
|
||||||
.set(config.defaultHeaders())
|
.set(config.defaultHeaders())
|
||||||
.expect(204)
|
.expect(204)
|
||||||
|
|
||||||
await getView(view._id!).expect(404)
|
await config.getViewV2(view._id!).expect(404)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -647,6 +647,12 @@ class TestConfiguration {
|
||||||
return this._req(view, null, controllers.view.v2.save)
|
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
|
// AUTOMATION
|
||||||
|
|
||||||
async createAutomation(config?: any) {
|
async createAutomation(config?: any) {
|
||||||
|
|
Loading…
Reference in New Issue