mirror of
https://github.com/strapi/strapi.git
synced 2025-08-10 09:47:46 +00:00
refactor the useSettingsForm unit test
This commit is contained in:
parent
536b2ccd4b
commit
b58307c990
@ -3,7 +3,6 @@ import { setupServer } from 'msw/node';
|
||||
import { rest } from 'msw';
|
||||
import { renderHook, act } from '@testing-library/react-hooks';
|
||||
import { IntlProvider } from 'react-intl';
|
||||
import omit from 'lodash/omit';
|
||||
import useSettingsForm from '../index';
|
||||
|
||||
const toggleNotification = jest.fn();
|
||||
@ -19,7 +18,7 @@ jest.mock('../../../utils', () => ({
|
||||
checkFormValidity: () => (null),
|
||||
}));
|
||||
|
||||
jest.mock('lodash/omit');
|
||||
// jest.mock('lodash/omit');
|
||||
|
||||
const handlers = [
|
||||
rest.put('*/providers/options', (req, res, ctx) =>
|
||||
@ -105,13 +104,23 @@ describe('useSettingsForm', () => {
|
||||
});
|
||||
|
||||
test('submit new providers options with duplications', async () => {
|
||||
const cbSucc = jest.fn();
|
||||
const ssoLockedRolesWithDuplications = [ '1', '2', '2', '3' ];
|
||||
omit.mockReturnValueOnce({
|
||||
server.use(
|
||||
rest.get('*/providers/options', (req, res, ctx) =>
|
||||
res.once(
|
||||
ctx.status(200),
|
||||
ctx.json({
|
||||
data: {
|
||||
autoRegister: false,
|
||||
defaultRole: '1',
|
||||
defaultRole: "1",
|
||||
ssoLockedRoles: ssoLockedRolesWithDuplications
|
||||
});
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
const cbSucc = jest.fn();
|
||||
|
||||
const { result, waitFor } = setup('/admin/providers/options', {}, cbSucc, ['autoRegister', 'defaultRole', 'ssoLockedRoles'] );
|
||||
await waitFor(() => expect(result.current[0].isLoading).toBe(false));
|
||||
|
Loading…
x
Reference in New Issue
Block a user