Mock redis shutdown method to avoid errors

This commit is contained in:
Andrew Kingston 2021-07-07 09:34:56 +01:00
parent e00a37d707
commit 7b841e709a
1 changed files with 14 additions and 10 deletions

View File

@ -9,9 +9,13 @@ jest.mock("../../../utilities/redis", () => ({
updateLock: jest.fn(), updateLock: jest.fn(),
setDebounce: jest.fn(), setDebounce: jest.fn(),
checkDebounce: jest.fn(), checkDebounce: jest.fn(),
shutdown: jest.fn(),
})) }))
const { clearAllApps, checkBuilderEndpoint } = require("./utilities/TestFunctions") const {
clearAllApps,
checkBuilderEndpoint,
} = require("./utilities/TestFunctions")
const setup = require("./utilities") const setup = require("./utilities")
const { AppStatus } = require("../../../db/utils") const { AppStatus } = require("../../../db/utils")
@ -32,7 +36,7 @@ describe("/applications", () => {
.post("/api/applications") .post("/api/applications")
.send({ name: "My App" }) .send({ name: "My App" })
.set(config.defaultHeaders()) .set(config.defaultHeaders())
.expect('Content-Type', /json/) .expect("Content-Type", /json/)
.expect(200) .expect(200)
expect(res.body._id).toBeDefined() expect(res.body._id).toBeDefined()
}) })
@ -42,7 +46,7 @@ describe("/applications", () => {
config, config,
method: "POST", method: "POST",
url: `/api/applications`, url: `/api/applications`,
body: { name: "My App" } body: { name: "My App" },
}) })
}) })
}) })
@ -55,7 +59,7 @@ describe("/applications", () => {
const res = await request const res = await request
.get(`/api/applications?status=${AppStatus.DEV}`) .get(`/api/applications?status=${AppStatus.DEV}`)
.set(config.defaultHeaders()) .set(config.defaultHeaders())
.expect('Content-Type', /json/) .expect("Content-Type", /json/)
.expect(200) .expect(200)
// two created apps + the inited app // two created apps + the inited app
@ -68,7 +72,7 @@ describe("/applications", () => {
const res = await request const res = await request
.get(`/api/applications/${config.getAppId()}/definition`) .get(`/api/applications/${config.getAppId()}/definition`)
.set(config.defaultHeaders()) .set(config.defaultHeaders())
.expect('Content-Type', /json/) .expect("Content-Type", /json/)
.expect(200) .expect(200)
// should have empty packages // should have empty packages
expect(res.body.screens.length).toEqual(1) expect(res.body.screens.length).toEqual(1)
@ -81,7 +85,7 @@ describe("/applications", () => {
const res = await request const res = await request
.get(`/api/applications/${config.getAppId()}/appPackage`) .get(`/api/applications/${config.getAppId()}/appPackage`)
.set(config.defaultHeaders()) .set(config.defaultHeaders())
.expect('Content-Type', /json/) .expect("Content-Type", /json/)
.expect(200) .expect(200)
expect(res.body.application).toBeDefined() expect(res.body.application).toBeDefined()
expect(res.body.screens.length).toEqual(1) expect(res.body.screens.length).toEqual(1)
@ -94,10 +98,10 @@ describe("/applications", () => {
const res = await request const res = await request
.put(`/api/applications/${config.getAppId()}`) .put(`/api/applications/${config.getAppId()}`)
.send({ .send({
name: "TEST_APP" name: "TEST_APP",
}) })
.set(config.defaultHeaders()) .set(config.defaultHeaders())
.expect('Content-Type', /json/) .expect("Content-Type", /json/)
.expect(200) .expect(200)
expect(res.body.rev).toBeDefined() expect(res.body.rev).toBeDefined()
}) })
@ -113,14 +117,14 @@ describe("/applications", () => {
name: "UPDATED_NAME", name: "UPDATED_NAME",
}) })
.set(headers) .set(headers)
.expect('Content-Type', /json/) .expect("Content-Type", /json/)
.expect(200) .expect(200)
expect(res.body.rev).toBeDefined() expect(res.body.rev).toBeDefined()
// retrieve the app to check it // retrieve the app to check it
const getRes = await request const getRes = await request
.get(`/api/applications/${config.getAppId()}/appPackage`) .get(`/api/applications/${config.getAppId()}/appPackage`)
.set(headers) .set(headers)
.expect('Content-Type', /json/) .expect("Content-Type", /json/)
.expect(200) .expect(200)
expect(getRes.body.application.updatedAt).toBeDefined() expect(getRes.body.application.updatedAt).toBeDefined()
}) })