0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00
logto/packages/core/src/routes/setting.test.ts

44 lines
1.1 KiB
TypeScript
Raw Normal View History

import { Setting, CreateSetting } from '@logto/schemas';
import { mockSetting } from '@/__mocks__';
import { createRequester } from '@/utils/test-utils';
import settingRoutes from './setting';
jest.mock('@/queries/setting', () => ({
getSetting: jest.fn(async (): Promise<Setting> => mockSetting),
updateSetting: jest.fn(
async (data: Partial<CreateSetting>): Promise<Setting> => ({
...mockSetting,
...data,
})
),
}));
describe('settings routes', () => {
const roleRequester = createRequester({ authedRoutes: settingRoutes });
it('GET /settings', async () => {
const response = await roleRequester.get('/settings');
expect(response.status).toEqual(200);
const { id, ...rest } = mockSetting;
expect(response.body).toEqual(rest);
});
it('PATCH /settings', async () => {
const customDomain = 'silverhand-logto.io';
2022-04-09 09:06:41 -05:00
const adminConsole = {};
const response = await roleRequester.patch('/settings').send({
customDomain,
adminConsole,
});
expect(response.status).toEqual(200);
expect(response.body).toEqual({
customDomain,
adminConsole,
});
});
});