2022-02-21 16:42:48 +08:00
|
|
|
import { Role } from '@logto/schemas';
|
|
|
|
|
|
|
|
import { mockRole } from '@/utils/mock';
|
|
|
|
import { createRequester } from '@/utils/test-utils';
|
|
|
|
|
|
|
|
import roleRoutes from './role';
|
|
|
|
|
|
|
|
jest.mock('@/queries/roles', () => ({
|
|
|
|
findAllRoles: jest.fn(async (): Promise<Role[]> => [mockRole]),
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('role routes', () => {
|
2022-02-23 11:09:26 +08:00
|
|
|
const roleRequester = createRequester({ authedRoutes: roleRoutes });
|
2022-02-21 16:42:48 +08:00
|
|
|
|
|
|
|
it('GET /roles', async () => {
|
|
|
|
const response = await roleRequester.get('/roles');
|
|
|
|
expect(response.status).toEqual(200);
|
|
|
|
expect(response.body).toEqual([mockRole]);
|
|
|
|
});
|
|
|
|
});
|