mirror of
https://github.com/strapi/strapi.git
synced 2025-07-27 19:10:01 +00:00
add unit test
Signed-off-by: Pierre Noël <petersg83@gmail.com>
This commit is contained in:
parent
dd3bc76948
commit
89f408c67e
@ -76,5 +76,24 @@ describe('Role', () => {
|
||||
expect(dbFind).toHaveBeenCalledWith({ _limit: -1 });
|
||||
expect(foundRoles).toStrictEqual(roles);
|
||||
});
|
||||
test('Fetches all roles', async () => {
|
||||
const roles = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'super_admin',
|
||||
description: "Have all permissions. Can't be delete",
|
||||
},
|
||||
];
|
||||
const dbFind = jest.fn(() => Promise.resolve(roles));
|
||||
|
||||
global.strapi = {
|
||||
query: () => ({ find: dbFind }),
|
||||
};
|
||||
|
||||
const fetchedRole = await roleService.fetchAll();
|
||||
|
||||
expect(dbFind).toHaveBeenCalled();
|
||||
expect(fetchedRole).toStrictEqual(roles);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user