Refactor create app
This commit is contained in:
parent
9c55bbf9cf
commit
185d55a3f4
|
@ -40,10 +40,12 @@ export default class AppApi {
|
||||||
return [response, json]
|
return [response, json]
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(body: any): Promise<[Response, Partial<App>]> {
|
async create(body: any): Promise<Partial<App>> {
|
||||||
const response = await this.api.post(`/applications`, { body })
|
const response = await this.api.post(`/applications`, { body })
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
return [response, json]
|
expect(response).toHaveStatusCode(200)
|
||||||
|
expect(json._id).toBeDefined()
|
||||||
|
return json
|
||||||
}
|
}
|
||||||
|
|
||||||
async read(id: string): Promise<[Response, Application]> {
|
async read(id: string): Promise<[Response, Application]> {
|
||||||
|
|
|
@ -40,16 +40,12 @@ describe("Internal API - /applications endpoints", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("POST - Create an application", async () => {
|
it("POST - Create an application", async () => {
|
||||||
const [response, app] = await config.applications.create(generateApp())
|
config.applications.create(generateApp())
|
||||||
expect(response).toHaveStatusCode(200)
|
|
||||||
expect(app._id).toBeDefined()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("POST - Publish application", async () => {
|
it("POST - Publish application", async () => {
|
||||||
// create app
|
// create app
|
||||||
const [response, app] = await config.applications.create(generateApp())
|
const [response, app] = await config.applications.create(generateApp())
|
||||||
expect(response).toHaveStatusCode(200)
|
|
||||||
expect(app.appId).toBeDefined()
|
|
||||||
|
|
||||||
// publish app
|
// publish app
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
@ -87,9 +83,7 @@ describe("Internal API - /applications endpoints", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("POST - Sync application before deployment", async () => {
|
it("POST - Sync application before deployment", async () => {
|
||||||
const [response, app] = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
expect(response).toHaveStatusCode(200)
|
|
||||||
expect(app.appId).toBeDefined()
|
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
const [syncResponse, sync] = await config.applications.sync(
|
const [syncResponse, sync] = await config.applications.sync(
|
||||||
|
@ -102,9 +96,7 @@ describe("Internal API - /applications endpoints", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("POST - Sync application after deployment", async () => {
|
it("POST - Sync application after deployment", async () => {
|
||||||
const [response, app] = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
expect(response).toHaveStatusCode(200)
|
|
||||||
expect(app.appId).toBeDefined()
|
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
// publish app
|
// publish app
|
||||||
|
@ -120,9 +112,8 @@ describe("Internal API - /applications endpoints", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("PUT - Update an application", async () => {
|
it("PUT - Update an application", async () => {
|
||||||
const [response, app] = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
expect(response).toHaveStatusCode(200)
|
|
||||||
expect(app.appId).toBeDefined()
|
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
const [updateResponse, updatedApp] = await config.applications.update(
|
const [updateResponse, updatedApp] = await config.applications.update(
|
||||||
|
@ -136,9 +127,7 @@ describe("Internal API - /applications endpoints", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("POST - Revert Changes without changes", async () => {
|
it("POST - Revert Changes without changes", async () => {
|
||||||
const [response, app] = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
expect(response).toHaveStatusCode(200)
|
|
||||||
expect(app.appId).toBeDefined()
|
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
const [revertResponse, revert] = await config.applications.revert(
|
const [revertResponse, revert] = await config.applications.revert(
|
||||||
|
@ -152,9 +141,7 @@ describe("Internal API - /applications endpoints", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("POST - Revert Changes", async () => {
|
it("POST - Revert Changes", async () => {
|
||||||
const [response, app] = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
expect(response).toHaveStatusCode(200)
|
|
||||||
expect(app.appId).toBeDefined()
|
|
||||||
config.applications.api.appId = app.appId
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
// publish app
|
// publish app
|
||||||
|
@ -185,9 +172,7 @@ describe("Internal API - /applications endpoints", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("DELETE - Delete an application", async () => {
|
it("DELETE - Delete an application", async () => {
|
||||||
const [response, app] = await config.applications.create(generateApp())
|
const app = await config.applications.create(generateApp())
|
||||||
expect(response).toHaveStatusCode(200)
|
|
||||||
expect(app.appId).toBeDefined()
|
|
||||||
|
|
||||||
const [deleteResponse] = await config.applications.delete(<string>app.appId)
|
const [deleteResponse] = await config.applications.delete(<string>app.appId)
|
||||||
expect(deleteResponse).toHaveStatusCode(200)
|
expect(deleteResponse).toHaveStatusCode(200)
|
||||||
|
|
Loading…
Reference in New Issue