0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-13 21:30:30 -05:00
logto/packages/core/src/routes/role.test.ts
IceHe.xyz 5625b8838c
refactor(core): split mock.ts into __mocks__/*.ts (#510)
* chore(core,ui): coverage ignore src/__mocks__/

* chore(core): build excludes src/__mocks__/

* refactor(core): split mock.ts into __mocks__/*.ts
2022-04-08 09:47:09 +00:00

20 lines
571 B
TypeScript

import { Role } from '@logto/schemas';
import { mockRole } from '@/__mocks__';
import { createRequester } from '@/utils/test-utils';
import roleRoutes from './role';
jest.mock('@/queries/roles', () => ({
findAllRoles: jest.fn(async (): Promise<Role[]> => [mockRole]),
}));
describe('role routes', () => {
const roleRequester = createRequester({ authedRoutes: roleRoutes });
it('GET /roles', async () => {
const response = await roleRequester.get('/roles');
expect(response.status).toEqual(200);
expect(response.body).toEqual([mockRole]);
});
});