Fix unit tests
This commit is contained in:
parent
11fb7a0b25
commit
fc81644255
|
@ -45,7 +45,7 @@ module.exports = async (ctx, next) => {
|
||||||
const globalUser = await getCachedSelf(ctx, requestAppId)
|
const globalUser = await getCachedSelf(ctx, requestAppId)
|
||||||
appId = requestAppId
|
appId = requestAppId
|
||||||
// retrieving global user gets the right role
|
// retrieving global user gets the right role
|
||||||
roleId = globalUser.roleId
|
roleId = globalUser.roleId || roleId
|
||||||
}
|
}
|
||||||
|
|
||||||
// nothing more to do
|
// nothing more to do
|
||||||
|
|
|
@ -127,8 +127,8 @@ describe("Current app middleware", () => {
|
||||||
} else {
|
} else {
|
||||||
expect(cookieFn).not.toHaveBeenCalled()
|
expect(cookieFn).not.toHaveBeenCalled()
|
||||||
}
|
}
|
||||||
expect(config.ctx.roleId).toEqual("BASIC")
|
expect(config.ctx.roleId).toEqual("PUBLIC")
|
||||||
expect(config.ctx.user.role._id).toEqual("BASIC")
|
expect(config.ctx.user.role._id).toEqual("PUBLIC")
|
||||||
expect(config.ctx.appId).toEqual("app_test")
|
expect(config.ctx.appId).toEqual("app_test")
|
||||||
expect(config.next).toHaveBeenCalled()
|
expect(config.next).toHaveBeenCalled()
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ describe("Current app middleware", () => {
|
||||||
return "app_test"
|
return "app_test"
|
||||||
},
|
},
|
||||||
setCookie: jest.fn(),
|
setCookie: jest.fn(),
|
||||||
getCookie: () => ({appId: "app_test", roleId: "BASIC"}),
|
getCookie: () => ({appId: "app_test", roleId: "PUBLIC"}),
|
||||||
},
|
},
|
||||||
constants: { Cookies: {} },
|
constants: { Cookies: {} },
|
||||||
}))
|
}))
|
||||||
|
|
Loading…
Reference in New Issue