1
0
Fork 0
mirror of synced 2024-10-04 03:54:37 +13:00

Fix unit tests

This commit is contained in:
Rory Powell 2021-10-12 14:03:47 +01:00
parent 3f02e83386
commit 33a72b29d1
2 changed files with 4 additions and 4 deletions

View file

@ -45,7 +45,7 @@ module.exports = async (ctx, next) => {
const globalUser = await getCachedSelf(ctx, requestAppId)
appId = requestAppId
// retrieving global user gets the right role
roleId = globalUser.roleId
roleId = globalUser.roleId || roleId
}
// nothing more to do

View file

@ -127,8 +127,8 @@ describe("Current app middleware", () => {
} else {
expect(cookieFn).not.toHaveBeenCalled()
}
expect(config.ctx.roleId).toEqual("BASIC")
expect(config.ctx.user.role._id).toEqual("BASIC")
expect(config.ctx.roleId).toEqual("PUBLIC")
expect(config.ctx.user.role._id).toEqual("PUBLIC")
expect(config.ctx.appId).toEqual("app_test")
expect(config.next).toHaveBeenCalled()
}
@ -163,7 +163,7 @@ describe("Current app middleware", () => {
return "app_test"
},
setCookie: jest.fn(),
getCookie: () => ({appId: "app_test", roleId: "BASIC"}),
getCookie: () => ({appId: "app_test", roleId: "PUBLIC"}),
},
constants: { Cookies: {} },
}))