2022-06-14 03:39:43 -05:00
|
|
|
import { render } from '@testing-library/react';
|
2022-04-22 08:33:13 -05:00
|
|
|
import React from 'react';
|
2022-06-14 03:39:43 -05:00
|
|
|
import { Provider } from 'react-redux';
|
2020-01-13 01:03:22 -06:00
|
|
|
import { mockToolkitActionCreator } from 'test/core/redux/mocks';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2022-06-14 03:39:43 -05:00
|
|
|
import { configureStore } from 'app/store/configureStore';
|
2022-04-22 08:33:13 -05:00
|
|
|
import { Invitee, OrgUser } from 'app/types';
|
|
|
|
|
2022-11-30 07:24:53 -06:00
|
|
|
import { Props, UsersListPageUnconnected } from './UsersListPage';
|
2023-01-09 02:54:33 -06:00
|
|
|
import { pageChanged } from './state/reducers';
|
2018-10-03 02:43:10 -05:00
|
|
|
|
|
|
|
jest.mock('../../core/app_events', () => ({
|
|
|
|
emit: jest.fn(),
|
|
|
|
}));
|
|
|
|
|
2022-06-14 03:39:43 -05:00
|
|
|
jest.mock('app/core/core', () => ({
|
2022-05-25 06:56:36 -05:00
|
|
|
contextSrv: {
|
|
|
|
user: { orgId: 1 },
|
2022-06-14 03:39:43 -05:00
|
|
|
hasAccess: () => false,
|
|
|
|
licensedAccessControlEnabled: () => false,
|
2022-05-25 06:56:36 -05:00
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
2018-10-03 02:43:10 -05:00
|
|
|
const setup = (propOverrides?: object) => {
|
2022-06-14 03:39:43 -05:00
|
|
|
const store = configureStore();
|
2018-10-03 02:43:10 -05:00
|
|
|
const props: Props = {
|
|
|
|
users: [] as OrgUser[],
|
|
|
|
invitees: [] as Invitee[],
|
|
|
|
searchQuery: '',
|
2023-01-09 02:54:33 -06:00
|
|
|
page: 1,
|
|
|
|
totalPages: 1,
|
|
|
|
perPage: 30,
|
2018-10-03 02:43:10 -05:00
|
|
|
externalUserMngInfo: '',
|
2022-02-21 05:37:49 -06:00
|
|
|
fetchInvitees: jest.fn(),
|
2018-10-03 02:43:10 -05:00
|
|
|
loadUsers: jest.fn(),
|
|
|
|
updateUser: jest.fn(),
|
|
|
|
removeUser: jest.fn(),
|
2023-01-09 02:54:33 -06:00
|
|
|
changePage: mockToolkitActionCreator(pageChanged),
|
|
|
|
isLoading: false,
|
2018-10-03 02:43:10 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
Object.assign(props, propOverrides);
|
|
|
|
|
2022-06-14 03:39:43 -05:00
|
|
|
render(
|
|
|
|
<Provider store={store}>
|
2022-11-30 07:24:53 -06:00
|
|
|
<UsersListPageUnconnected {...props} />
|
2022-06-14 03:39:43 -05:00
|
|
|
</Provider>
|
|
|
|
);
|
2018-10-03 02:43:10 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
describe('Render', () => {
|
|
|
|
it('should render component', () => {
|
2022-06-14 03:39:43 -05:00
|
|
|
expect(setup).not.toThrow();
|
2018-10-03 02:43:10 -05:00
|
|
|
});
|
2018-10-11 04:49:34 -05:00
|
|
|
|
|
|
|
it('should render List page', () => {
|
2022-06-14 03:39:43 -05:00
|
|
|
expect(() =>
|
|
|
|
setup({
|
|
|
|
hasFetched: true,
|
|
|
|
})
|
|
|
|
).not.toThrow();
|
2018-10-11 04:49:34 -05:00
|
|
|
});
|
2018-10-03 02:43:10 -05:00
|
|
|
});
|