mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
UserListPage: Convert tests to RTL (#50717)
This commit is contained in:
parent
44ffbfd6aa
commit
701edcdc46
@ -143,9 +143,6 @@ exports[`no enzyme tests`] = {
|
||||
"public/app/features/org/OrgDetailsPage.test.tsx:3835042085": [
|
||||
[0, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"public/app/features/users/UsersListPage.test.tsx:2518052139": [
|
||||
[0, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/components/ConfigEditor.test.tsx:227258837": [
|
||||
[0, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { shallow } from 'enzyme';
|
||||
import { render } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { Provider } from 'react-redux';
|
||||
import { mockToolkitActionCreator } from 'test/core/redux/mocks';
|
||||
|
||||
import { NavModel } from '@grafana/data';
|
||||
import { configureStore } from 'app/store/configureStore';
|
||||
import { Invitee, OrgUser } from 'app/types';
|
||||
|
||||
import { Props, UsersListPage } from './UsersListPage';
|
||||
@ -12,13 +14,16 @@ jest.mock('../../core/app_events', () => ({
|
||||
emit: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('app/core/services/context_srv', () => ({
|
||||
jest.mock('app/core/core', () => ({
|
||||
contextSrv: {
|
||||
user: { orgId: 1 },
|
||||
hasAccess: () => false,
|
||||
licensedAccessControlEnabled: () => false,
|
||||
},
|
||||
}));
|
||||
|
||||
const setup = (propOverrides?: object) => {
|
||||
const store = configureStore();
|
||||
const props: Props = {
|
||||
navModel: {
|
||||
main: {
|
||||
@ -44,27 +49,23 @@ const setup = (propOverrides?: object) => {
|
||||
|
||||
Object.assign(props, propOverrides);
|
||||
|
||||
const wrapper = shallow(<UsersListPage {...props} />);
|
||||
const instance = wrapper.instance() as UsersListPage;
|
||||
|
||||
return {
|
||||
wrapper,
|
||||
instance,
|
||||
};
|
||||
render(
|
||||
<Provider store={store}>
|
||||
<UsersListPage {...props} />
|
||||
</Provider>
|
||||
);
|
||||
};
|
||||
|
||||
describe('Render', () => {
|
||||
it('should render component', () => {
|
||||
const { wrapper } = setup();
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(setup).not.toThrow();
|
||||
});
|
||||
|
||||
it('should render List page', () => {
|
||||
const { wrapper } = setup({
|
||||
hasFetched: true,
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(() =>
|
||||
setup({
|
||||
hasFetched: true,
|
||||
})
|
||||
).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
@ -4,8 +4,8 @@ import { connect, ConnectedProps } from 'react-redux';
|
||||
import { renderMarkdown } from '@grafana/data';
|
||||
import { HorizontalGroup, Pagination, VerticalGroup } from '@grafana/ui';
|
||||
import Page from 'app/core/components/Page/Page';
|
||||
import { contextSrv } from 'app/core/core';
|
||||
import { getNavModel } from 'app/core/selectors/navModel';
|
||||
import { contextSrv } from 'app/core/services/context_srv';
|
||||
import { OrgUser, OrgRole, StoreState } from 'app/types';
|
||||
|
||||
import InviteesTable from '../invites/InviteesTable';
|
||||
|
@ -1,69 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Render should render List page 1`] = `
|
||||
<Page
|
||||
navModel={
|
||||
Object {
|
||||
"main": Object {
|
||||
"text": "Configuration",
|
||||
},
|
||||
"node": Object {
|
||||
"text": "Users",
|
||||
},
|
||||
}
|
||||
}
|
||||
>
|
||||
<PageContents
|
||||
isLoading={false}
|
||||
>
|
||||
<Connect(UsersActionBar)
|
||||
onShowInvites={[Function]}
|
||||
showInvites={false}
|
||||
/>
|
||||
<VerticalGroup
|
||||
spacing="md"
|
||||
>
|
||||
<UsersTable
|
||||
onRemoveUser={[Function]}
|
||||
onRoleChange={[Function]}
|
||||
orgId={1}
|
||||
users={Array []}
|
||||
/>
|
||||
<HorizontalGroup
|
||||
justify="flex-end"
|
||||
>
|
||||
<Pagination
|
||||
currentPage={1}
|
||||
hideWhenSinglePage={true}
|
||||
numberOfPages={0}
|
||||
onNavigate={[MockFunction]}
|
||||
/>
|
||||
</HorizontalGroup>
|
||||
</VerticalGroup>
|
||||
</PageContents>
|
||||
</Page>
|
||||
`;
|
||||
|
||||
exports[`Render should render component 1`] = `
|
||||
<Page
|
||||
navModel={
|
||||
Object {
|
||||
"main": Object {
|
||||
"text": "Configuration",
|
||||
},
|
||||
"node": Object {
|
||||
"text": "Users",
|
||||
},
|
||||
}
|
||||
}
|
||||
>
|
||||
<PageContents
|
||||
isLoading={true}
|
||||
>
|
||||
<Connect(UsersActionBar)
|
||||
onShowInvites={[Function]}
|
||||
showInvites={false}
|
||||
/>
|
||||
</PageContents>
|
||||
</Page>
|
||||
`;
|
Loading…
Reference in New Issue
Block a user