diff --git a/.betterer.results b/.betterer.results index 4cc661563ee..9d094e27732 100644 --- a/.betterer.results +++ b/.betterer.results @@ -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"] ], diff --git a/public/app/features/org/OrgProfile.test.tsx b/public/app/features/org/OrgProfile.test.tsx index 459ad6cbe6a..29e604cac7a 100644 --- a/public/app/features/org/OrgProfile.test.tsx +++ b/public/app/features/org/OrgProfile.test.tsx @@ -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(); -}; + it('should render without crashing', () => { + expect(() => render()).not.toThrow(); + }); + + it('should show the current org name', () => { + render(); + + const orgNameInput = screen.getByLabelText('Organization name'); + + expect(orgNameInput).toHaveValue('Main org'); + }); + + it('can update the current org name', async () => { + render(); + + const orgNameInput = screen.getByLabelText('Organization name'); + const submitButton = screen.getByRole('button', { name: 'Update organization name' }); + + expect(orgNameInput).toHaveValue('Main org'); -describe('Render', () => { - it('should render component', () => { - const wrapper = setup(); + await userEvent.clear(orgNameInput); + await userEvent.type(orgNameInput, 'New org name'); + await userEvent.click(submitButton); - expect(wrapper).toMatchSnapshot(); + expect(props.onSubmit).toHaveBeenCalledWith('New org name'); }); }); diff --git a/public/app/features/org/__snapshots__/OrgProfile.test.tsx.snap b/public/app/features/org/__snapshots__/OrgProfile.test.tsx.snap deleted file mode 100644 index c6b257b3976..00000000000 --- a/public/app/features/org/__snapshots__/OrgProfile.test.tsx.snap +++ /dev/null @@ -1,14 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Render should render component 1`] = ` -
- - -`;