Skip to content

Commit

Permalink
[tests] Emotion test + convert Enzyme to RTL
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Aug 9, 2024
1 parent 1384bb1 commit f137bce
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*/

import React from 'react';
import { mount } from 'enzyme';

import { findTestSubject, requiredProps } from '../../../test';
import { fireEvent } from '@testing-library/react';
import { requiredProps } from '../../../test';
import { shouldRenderCustomStyles } from '../../../test/internal';
import { render } from '../../../test/rtl';

import { EuiForm } from '../form';
Expand All @@ -22,6 +22,8 @@ jest.mock('../../', () => ({
}));

describe('EuiFormControlLayout', () => {
shouldRenderCustomStyles(<EuiFormControlLayout />);

test('is rendered', () => {
const { container } = render(
<EuiFormControlLayout {...requiredProps}>
Expand Down Expand Up @@ -77,11 +79,12 @@ describe('EuiFormControlLayout', () => {
'data-test-subj': 'myIcon',
};

const component = mount(<EuiFormControlLayout icon={icon} />);
const { getByTestSubject } = render(
<EuiFormControlLayout icon={icon} />
);

const closeButton = findTestSubject(component, 'myIcon');
closeButton.simulate('click');
expect(icon.onClick).toBeCalled();
fireEvent.click(getByTestSubject('myIcon'));
expect(icon.onClick).toHaveBeenCalled();
});
});
});
Expand All @@ -106,11 +109,12 @@ describe('EuiFormControlLayout', () => {
'data-test-subj': 'clearButton',
};

const component = mount(<EuiFormControlLayout clear={clear} />);
const { getByTestSubject } = render(
<EuiFormControlLayout clear={clear} />
);

const closeButton = findTestSubject(component, 'clearButton');
closeButton.simulate('click');
expect(clear.onClick).toBeCalled();
fireEvent.click(getByTestSubject('clearButton'));
expect(clear.onClick).toHaveBeenCalled();
});
});
});
Expand Down

0 comments on commit f137bce

Please sign in to comment.