forked from wangziqi/gongxue-base
test: harden business boundary conditions
This commit is contained in:
@@ -33,6 +33,23 @@ describe('JwtStrategy', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('recognizes the canonical super_admin role code even when the display name changes', async () => {
|
||||
const userRepo = {
|
||||
findOne: jest.fn().mockResolvedValue({
|
||||
id: 1,
|
||||
username: 'admin',
|
||||
isActive: true,
|
||||
isArchived: false,
|
||||
roles: [{ name: '系统管理员', code: 'super_admin', status: 1, permissions: [] }],
|
||||
}),
|
||||
};
|
||||
const strategy = new JwtStrategy(config as never, userRepo as never);
|
||||
|
||||
await expect(strategy.validate({ sub: 1 })).resolves.toEqual(
|
||||
expect.objectContaining({ isSuperAdmin: true }),
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
[{ id: 7, isActive: false, isArchived: false, roles: [] }],
|
||||
[{ id: 7, isActive: true, isArchived: true, roles: [] }],
|
||||
|
||||
Reference in New Issue
Block a user