Fix application.spec.ts's reliance on the node-fetch mock.
This commit is contained in:
parent
fddf93c005
commit
3d20d4ccb7
|
@ -20,6 +20,7 @@ import { type App } from "@budibase/types"
|
||||||
import tk from "timekeeper"
|
import tk from "timekeeper"
|
||||||
import * as uuid from "uuid"
|
import * as uuid from "uuid"
|
||||||
import { structures } from "@budibase/backend-core/tests"
|
import { structures } from "@budibase/backend-core/tests"
|
||||||
|
import nock from "nock"
|
||||||
|
|
||||||
describe("/applications", () => {
|
describe("/applications", () => {
|
||||||
let config = setup.getConfig()
|
let config = setup.getConfig()
|
||||||
|
@ -35,6 +36,7 @@ describe("/applications", () => {
|
||||||
throw new Error("Failed to publish app")
|
throw new Error("Failed to publish app")
|
||||||
}
|
}
|
||||||
jest.clearAllMocks()
|
jest.clearAllMocks()
|
||||||
|
nock.cleanAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
// These need to go first for the app totals to make sense
|
// These need to go first for the app totals to make sense
|
||||||
|
@ -324,18 +326,33 @@ describe("/applications", () => {
|
||||||
|
|
||||||
describe("delete", () => {
|
describe("delete", () => {
|
||||||
it("should delete published app and dev apps with dev app ID", async () => {
|
it("should delete published app and dev apps with dev app ID", async () => {
|
||||||
|
const prodAppId = app.appId.replace("_dev", "")
|
||||||
|
nock("http://localhost:10000")
|
||||||
|
.delete(`/api/global/roles/${prodAppId}`)
|
||||||
|
.reply(200, {})
|
||||||
|
|
||||||
await config.api.application.delete(app.appId)
|
await config.api.application.delete(app.appId)
|
||||||
expect(events.app.deleted).toHaveBeenCalledTimes(1)
|
expect(events.app.deleted).toHaveBeenCalledTimes(1)
|
||||||
expect(events.app.unpublished).toHaveBeenCalledTimes(1)
|
expect(events.app.unpublished).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should delete published app and dev app with prod app ID", async () => {
|
it("should delete published app and dev app with prod app ID", async () => {
|
||||||
await config.api.application.delete(app.appId.replace("_dev", ""))
|
const prodAppId = app.appId.replace("_dev", "")
|
||||||
|
nock("http://localhost:10000")
|
||||||
|
.delete(`/api/global/roles/${prodAppId}`)
|
||||||
|
.reply(200, {})
|
||||||
|
|
||||||
|
await config.api.application.delete(prodAppId)
|
||||||
expect(events.app.deleted).toHaveBeenCalledTimes(1)
|
expect(events.app.deleted).toHaveBeenCalledTimes(1)
|
||||||
expect(events.app.unpublished).toHaveBeenCalledTimes(1)
|
expect(events.app.unpublished).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should be able to delete an app after SQS_SEARCH_ENABLE has been set but app hasn't been migrated", async () => {
|
it("should be able to delete an app after SQS_SEARCH_ENABLE has been set but app hasn't been migrated", async () => {
|
||||||
|
const prodAppId = app.appId.replace("_dev", "")
|
||||||
|
nock("http://localhost:10000")
|
||||||
|
.delete(`/api/global/roles/${prodAppId}`)
|
||||||
|
.reply(200, {})
|
||||||
|
|
||||||
await config.withCoreEnv({ SQS_SEARCH_ENABLE: "true" }, async () => {
|
await config.withCoreEnv({ SQS_SEARCH_ENABLE: "true" }, async () => {
|
||||||
await config.api.application.delete(app.appId)
|
await config.api.application.delete(app.appId)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue