mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Admin: Add unified users page * Admin: Combine admin and org components * Admin: Add combined route * Admin: Show combined page in nav * Admin: Update translation * Admin: Update description * Admin: Update description on backend * Admin: Update translations * Admin: Use dynamic imports
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
import { render } from '@testing-library/react';
|
|
import React from 'react';
|
|
import { Provider } from 'react-redux';
|
|
import { mockToolkitActionCreator } from 'test/core/redux/mocks';
|
|
|
|
import { configureStore } from 'app/store/configureStore';
|
|
import { Invitee, OrgUser } from 'app/types';
|
|
|
|
import { Props, UsersListPageUnconnected } from './UsersListPage';
|
|
import { setUsersSearchPage, setUsersSearchQuery } from './state/reducers';
|
|
|
|
jest.mock('../../core/app_events', () => ({
|
|
emit: jest.fn(),
|
|
}));
|
|
|
|
jest.mock('app/core/core', () => ({
|
|
contextSrv: {
|
|
user: { orgId: 1 },
|
|
hasAccess: () => false,
|
|
licensedAccessControlEnabled: () => false,
|
|
},
|
|
}));
|
|
|
|
const setup = (propOverrides?: object) => {
|
|
const store = configureStore();
|
|
const props: Props = {
|
|
users: [] as OrgUser[],
|
|
invitees: [] as Invitee[],
|
|
searchQuery: '',
|
|
searchPage: 1,
|
|
externalUserMngInfo: '',
|
|
fetchInvitees: jest.fn(),
|
|
loadUsers: jest.fn(),
|
|
updateUser: jest.fn(),
|
|
removeUser: jest.fn(),
|
|
setUsersSearchQuery: mockToolkitActionCreator(setUsersSearchQuery),
|
|
setUsersSearchPage: mockToolkitActionCreator(setUsersSearchPage),
|
|
hasFetched: false,
|
|
};
|
|
|
|
Object.assign(props, propOverrides);
|
|
|
|
render(
|
|
<Provider store={store}>
|
|
<UsersListPageUnconnected {...props} />
|
|
</Provider>
|
|
);
|
|
};
|
|
|
|
describe('Render', () => {
|
|
it('should render component', () => {
|
|
expect(setup).not.toThrow();
|
|
});
|
|
|
|
it('should render List page', () => {
|
|
expect(() =>
|
|
setup({
|
|
hasFetched: true,
|
|
})
|
|
).not.toThrow();
|
|
});
|
|
});
|