diff --git a/UNRELEASED.md b/UNRELEASED.md index 51453a78f96..bcd834e230c 100644 --- a/UNRELEASED.md +++ b/UNRELEASED.md @@ -73,6 +73,7 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f - Modernized tests for Pane, Section, PositionedOverlay, SingleThumb, RangeSlider, and ConnectedFilter components ([#4429](https://github.com/Shopify/polaris-react/pull/4429)) - Modernized tests for ContextualSaveBar and DataTable and its subcomponents ([#4397](https://github.com/Shopify/polaris-react/pull/4397)) - Modernized tests for IndexTable, Indicator, InlineError, KeyboardKey, and KeypressListener components([#4431](https://github.com/Shopify/polaris-react/pull/4431)) +- Modernized tests for OptionList and its subcomponents ([#4441](https://github.com/Shopify/polaris-react/pull/4441)) - Modernized tests for Modal ([#4433](https://github.com/Shopify/polaris-react/pull/4433)) - Modernized tests for Navigation and Navigation.Section ([#4440](https://github.com/Shopify/polaris-react/pull/4440)) - Modernized tests for EmptyState component ([#4427](https://github.com/Shopify/polaris-react/pull/4427)) diff --git a/src/components/OptionList/components/Checkbox/tests/Checkbox.test.tsx b/src/components/OptionList/components/Checkbox/tests/Checkbox.test.tsx index c3c60f64176..84fb79d13ee 100644 --- a/src/components/OptionList/components/Checkbox/tests/Checkbox.test.tsx +++ b/src/components/OptionList/components/Checkbox/tests/Checkbox.test.tsx @@ -1,6 +1,4 @@ import React from 'react'; -// eslint-disable-next-line no-restricted-imports -import {mountWithAppProvider} from 'test-utilities/legacy'; import {mountWithApp} from 'test-utilities'; import {Key} from '../../../../../types'; @@ -17,24 +15,19 @@ describe('', () => { }; it('sets pass through props for input', () => { - const input = mountWithAppProvider().find( - 'input', - ); - const {checked, disabled, id, name, value} = defaultProps; - - expect(input.prop('checked')).toBe(checked); - expect(input.prop('disabled')).toBe(disabled); - expect(input.prop('id')).toBe(id); - expect(input.prop('name')).toBe(name); - expect(input.prop('value')).toBe(value); + const input = mountWithApp(); + + expect(input).toContainReactComponent('input', defaultProps); }); it('calls onChange', () => { const spy = jest.fn(); - mountWithAppProvider() - .find('input') - .simulate('change'); + const input = mountWithApp( + , + ).find('input'); + + input!.trigger('onChange'); expect(spy).toHaveBeenCalledTimes(1); }); @@ -73,6 +66,7 @@ describe('', () => { checkboxInput!.trigger('onChange', { currentTarget: checkboxInput!.domNode as HTMLInputElement, }); + expect(checkbox).not.toContainReactComponent('input', { className: 'Input keyFocused', }); diff --git a/src/components/OptionList/components/Option/tests/Option.test.tsx b/src/components/OptionList/components/Option/tests/Option.test.tsx index a4cb5a49d63..fb92c8fafbb 100644 --- a/src/components/OptionList/components/Option/tests/Option.test.tsx +++ b/src/components/OptionList/components/Option/tests/Option.test.tsx @@ -1,6 +1,4 @@ import React from 'react'; -// eslint-disable-next-line no-restricted-imports -import {mountWithAppProvider} from 'test-utilities/legacy'; import {mountWithApp} from 'test-utilities'; import {Checkbox} from '../../Checkbox'; @@ -18,27 +16,23 @@ describe('