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