Skip to content

Commit

Permalink
Migrating various tests from enzyme to testing-library.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisoelkers committed Oct 2, 2024
1 parent 5e0e886 commit af3c30b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/
import React from 'react';
import { mount } from 'wrappedEnzyme';
import { render, screen } from 'wrappedTestingLibrary';
import 'helpers/mocking/react-dom_mock';

import ContentPackEntityConfig from 'components/content-packs/ContentPackEntityConfig';

describe('<ContentPackEntityConfig />', () => {
it('should render with a entity', () => {
it('should render with a entity', async () => {
const entity = {
data: {
title: { '@type': 'string', '@value': 'franz' },
Expand All @@ -30,10 +30,11 @@ describe('<ContentPackEntityConfig />', () => {
};
const appliedParameter = [{ configKey: 'descr', paramName: 'descrParam' }];
const parameter = [{ name: 'descrParam', title: 'A descr Parameter', type: 'string' }];
const wrapper = mount(<ContentPackEntityConfig entity={entity}
appliedParameter={appliedParameter}
parameters={parameter} />);

expect(wrapper).toExist();
render(<ContentPackEntityConfig entity={entity}
appliedParameter={appliedParameter}
parameters={parameter} />);

await screen.findByText(/franz/i);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/
import React from 'react';
import { mount } from 'wrappedEnzyme';
import { render, screen } from 'wrappedTestingLibrary';
import 'helpers/mocking/react-dom_mock';

import ContentPackUploadControls from 'components/content-packs/ContentPackUploadControls';

describe('<ContentPackUploadControls />', () => {
it('should render', () => {
const wrapper = mount(<ContentPackUploadControls />);
it('should render', async () => {
render(<ContentPackUploadControls />);

expect(wrapper).toExist();
await screen.findByRole('button', { name: /upload/i });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/
import React from 'react';
import { mount } from 'wrappedEnzyme';
import { render, screen } from 'wrappedTestingLibrary';
import 'helpers/mocking/react-dom_mock';

import EditPatternModal from 'components/grok-patterns/EditPatternModal';

describe('<EditPatternModal />', () => {
it('should render a modal button with as edit', () => {
const wrapper = mount(<EditPatternModal savePattern={() => {}}
testPattern={() => {}}
validPatternName={() => {}} />);
it('should render a modal button with as edit', async () => {
render(<EditPatternModal savePattern={() => {}}
testPattern={() => {}}
validPatternName={() => {}} />);

expect(wrapper).toExist();
await screen.findByRole('button', { name: /edit/i });
});

it('should render a modal button with as create', () => {
const wrapper = mount(<EditPatternModal create
savePattern={() => {}}
testPattern={() => {}}
validPatternName={() => {}} />);
it('should render a modal button with as create', async () => {
render(<EditPatternModal create
savePattern={() => {}}
testPattern={() => {}}
validPatternName={() => {}} />);

expect(wrapper).toExist();
await screen.findByRole('button', { name: /create pattern/i });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/
import * as React from 'react';
import { mount } from 'wrappedEnzyme';
import { render } from 'wrappedTestingLibrary';

import EmptyAggregationContent from './EmptyAggregationContent';

Expand All @@ -25,7 +25,7 @@ describe('EmptyAggregationContext', () => {
it('calls render completion callback after first render', () => {
const onRenderComplete = jest.fn();

mount((
render((
<RenderCompletionCallback.Provider value={onRenderComplete}>
<EmptyAggregationContent toggleEdit={() => {}} editing={false} />
</RenderCompletionCallback.Provider>
Expand Down

0 comments on commit af3c30b

Please sign in to comment.