mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Convert OrgProfile test to RTL (#50525)
This commit is contained in:
parent
6151320020
commit
6da4feb2a9
@ -146,9 +146,6 @@ exports[`no enzyme tests`] = {
|
||||
"public/app/features/org/OrgDetailsPage.test.tsx:3835042085": [
|
||||
[0, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"public/app/features/org/OrgProfile.test.tsx:623809345": [
|
||||
[0, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"public/app/features/teams/TeamSettings.test.tsx:2043271249": [
|
||||
[0, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { shallow } from 'enzyme';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
|
||||
import OrgProfile, { Props } from './OrgProfile';
|
||||
@ -11,19 +12,36 @@ jest.mock('app/core/core', () => {
|
||||
};
|
||||
});
|
||||
|
||||
const setup = () => {
|
||||
describe('OrgProfile', () => {
|
||||
const props: Props = {
|
||||
orgName: 'Main org',
|
||||
onSubmit: jest.fn(),
|
||||
};
|
||||
|
||||
return shallow(<OrgProfile {...props} />);
|
||||
};
|
||||
it('should render without crashing', () => {
|
||||
expect(() => render(<OrgProfile {...props} />)).not.toThrow();
|
||||
});
|
||||
|
||||
describe('Render', () => {
|
||||
it('should render component', () => {
|
||||
const wrapper = setup();
|
||||
it('should show the current org name', () => {
|
||||
render(<OrgProfile {...props} />);
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
const orgNameInput = screen.getByLabelText('Organization name');
|
||||
|
||||
expect(orgNameInput).toHaveValue('Main org');
|
||||
});
|
||||
|
||||
it('can update the current org name', async () => {
|
||||
render(<OrgProfile {...props} />);
|
||||
|
||||
const orgNameInput = screen.getByLabelText('Organization name');
|
||||
const submitButton = screen.getByRole('button', { name: 'Update organization name' });
|
||||
|
||||
expect(orgNameInput).toHaveValue('Main org');
|
||||
|
||||
await userEvent.clear(orgNameInput);
|
||||
await userEvent.type(orgNameInput, 'New org name');
|
||||
await userEvent.click(submitButton);
|
||||
|
||||
expect(props.onSubmit).toHaveBeenCalledWith('New org name');
|
||||
});
|
||||
});
|
||||
|
@ -1,14 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Render should render component 1`] = `
|
||||
<Form
|
||||
defaultValues={
|
||||
Object {
|
||||
"orgName": "Main org",
|
||||
}
|
||||
}
|
||||
onSubmit={[Function]}
|
||||
>
|
||||
<Component />
|
||||
</Form>
|
||||
`;
|
Loading…
Reference in New Issue
Block a user