From f28974226485e7185857f172cc95c44456790b14 Mon Sep 17 00:00:00 2001 From: Richard Todd Date: Wed, 14 Jul 2021 18:06:19 -0400 Subject: [PATCH 1/3] Modernized tests - Breadcrumbs, BulkActions, Button, ButtonGroup Item, ButtonGroup --- UNRELEASED.md | 3 +++ .../test/AfterInitialMount.test.tsx | 6 +++--- .../AppProvider/tests/AppProvider.test.tsx | 12 +++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/UNRELEASED.md b/UNRELEASED.md index 9154ae3a2b2..badae1e937c 100644 --- a/UNRELEASED.md +++ b/UNRELEASED.md @@ -42,4 +42,7 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f - Modernized tests for Breadcrumbs, BulkActions, Button, ButtonGroup/Item, and ButtonGroup components([#4315](https://github.com/Shopify/polaris-react/pull/4315)) - Modernized tests for DualThumb ([#4341](https://github.com/Shopify/polaris-react/pull/4341)) +- Modernized tests for Breadcrumbs, BulkActions, Button, ButtonGroup/Item, and ButtonGroup components([#4315](https://github.com/Shopify/polaris-react/pull/4315)) +- Modernized tests for AppProvider, AfterInitialMount components([#4315](https://github.com/Shopify/polaris-react/pull/4331)) + ### Deprecations diff --git a/src/components/AfterInitialMount/test/AfterInitialMount.test.tsx b/src/components/AfterInitialMount/test/AfterInitialMount.test.tsx index c6afab0f23e..a87aae29d47 100644 --- a/src/components/AfterInitialMount/test/AfterInitialMount.test.tsx +++ b/src/components/AfterInitialMount/test/AfterInitialMount.test.tsx @@ -1,5 +1,5 @@ import React, {useEffect} from 'react'; -import {mount} from 'test-utilities'; +import {mountWithApp} from 'test-utilities/react-testing'; import {AfterInitialMount} from '../AfterInitialMount'; @@ -12,7 +12,7 @@ describe('AfterInitialMount', () => { return null; } - mount(} />); + mountWithApp(} />); expect(spy).toHaveBeenCalledTimes(1); }); @@ -31,7 +31,7 @@ describe('AfterInitialMount', () => { return null; } - const afterInitialMount = mount( + const afterInitialMount = mountWithApp( }> , diff --git a/src/components/AppProvider/tests/AppProvider.test.tsx b/src/components/AppProvider/tests/AppProvider.test.tsx index 5628bd9e879..60b59f194de 100644 --- a/src/components/AppProvider/tests/AppProvider.test.tsx +++ b/src/components/AppProvider/tests/AppProvider.test.tsx @@ -1,7 +1,5 @@ import React, {useContext} from 'react'; import {matchMedia} from '@shopify/jest-dom-mocks'; -// eslint-disable-next-line no-restricted-imports -import {mountWithAppProvider} from 'test-utilities/legacy'; import {mountWithApp} from 'test-utilities/react-testing'; import {MediaQueryProvider} from 'components/MediaQueryProvider'; @@ -19,21 +17,21 @@ describe('', () => { }); it('updates context when props change', () => { - const Child: React.SFC = () => { + const Child: React.FunctionComponent = () => { return useContext(LinkContext) ?
: null; }; const LinkComponent = () =>
; - const wrapper = mountWithAppProvider( + const wrapper = mountWithApp( , ); - expect(wrapper.find('#child')).toHaveLength(0); + expect(wrapper).not.toContainReactComponent('div', {id: 'child'}); wrapper.setProps({linkComponent: LinkComponent}); - wrapper.update(); - expect(wrapper.find('#child')).toHaveLength(1); + wrapper.forceUpdate(); + expect(wrapper).toContainReactComponent('div', {id: 'child'}); }); it('renders a MediaProvider', () => { From 560b7ffef24598141ca4d2201939c13be8756965 Mon Sep 17 00:00:00 2001 From: Richard Todd Date: Mon, 9 Aug 2021 09:53:36 -0400 Subject: [PATCH 2/3] Disabled style lint for class selector in IndexTable.scss --- src/components/IndexTable/IndexTable.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/IndexTable/IndexTable.scss b/src/components/IndexTable/IndexTable.scss index 5f5ccd43232..a41a135584e 100644 --- a/src/components/IndexTable/IndexTable.scss +++ b/src/components/IndexTable/IndexTable.scss @@ -148,6 +148,7 @@ $loading-panel-height: rem(53px); } } + // stylelint-disable-next-line selector-max-class &.TableRow-hovered.TableRow-selected { // stylelint-disable-next-line selector-max-class, selector-max-combinators, selector-max-specificity &, From cf9ff74d6d1b08ed39d8c5263512b318edaf274d Mon Sep 17 00:00:00 2001 From: Richard Todd Date: Mon, 9 Aug 2021 10:05:52 -0400 Subject: [PATCH 3/3] Removed dupes in UNRELEASED --- UNRELEASED.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/UNRELEASED.md b/UNRELEASED.md index badae1e937c..926214c7f0d 100644 --- a/UNRELEASED.md +++ b/UNRELEASED.md @@ -41,8 +41,6 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f - Modernized tests for FormLayout and some components of ColorPicker ([#4330](https://github.com/Shopify/polaris-react/pull/4330)) - Modernized tests for Breadcrumbs, BulkActions, Button, ButtonGroup/Item, and ButtonGroup components([#4315](https://github.com/Shopify/polaris-react/pull/4315)) - Modernized tests for DualThumb ([#4341](https://github.com/Shopify/polaris-react/pull/4341)) - -- Modernized tests for Breadcrumbs, BulkActions, Button, ButtonGroup/Item, and ButtonGroup components([#4315](https://github.com/Shopify/polaris-react/pull/4315)) - Modernized tests for AppProvider, AfterInitialMount components([#4315](https://github.com/Shopify/polaris-react/pull/4331)) ### Deprecations