diff --git a/UNRELEASED.md b/UNRELEASED.md
index 51453a78f96..8d5f5ec99dc 100644
--- a/UNRELEASED.md
+++ b/UNRELEASED.md
@@ -76,8 +76,7 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f
- 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))
-- Modernized tests for FilterControl, FilterCreator, FilterValueSelector, and DateSelector components ([#](https://github.com/Shopify/polaris-react/pull/))
-- Modernized tests for FilterControl, FilterCreator, FilterValueSelector, and DateSelector components ([#4438](https://github.com/Shopify/polaris-react/pull/4438))
- Modernized tests for Pagination, FilterControl, FilterCreator, FilterValueSelector, and DateSelector components ([#4438](https://github.com/Shopify/polaris-react/pull/4438))
+- Modernized tests for PopoverOverlay component([#4430](https://github.com/Shopify/polaris-react/pull/4430))
### Deprecations
diff --git a/src/components/Popover/components/PopoverOverlay/tests/PopoverOverlay.test.tsx b/src/components/Popover/components/PopoverOverlay/tests/PopoverOverlay.test.tsx
index f8ceb73dca9..42f3e62fb1b 100644
--- a/src/components/Popover/components/PopoverOverlay/tests/PopoverOverlay.test.tsx
+++ b/src/components/Popover/components/PopoverOverlay/tests/PopoverOverlay.test.tsx
@@ -1,10 +1,4 @@
import React, {useRef} from 'react';
-// eslint-disable-next-line no-restricted-imports
-import {
- mountWithAppProvider,
- ReactWrapper,
- trigger,
-} from 'test-utilities/legacy';
import {mountWithApp} from 'test-utilities/react-testing';
import {TextContainer, TextField, EventListener} from 'components';
@@ -60,7 +54,7 @@ describe('', () => {
);
it('passes activator to PositionedOverlay when active', () => {
- const popoverOverlay = mountWithAppProvider(
+ const popoverOverlay = mountWithApp(
', () => {
,
);
- expect(popoverOverlay.find(PositionedOverlay).prop('activator')).toBe(
+ expect(popoverOverlay).toContainReactComponent(PositionedOverlay, {
activator,
- );
+ });
});
it('passes fullWidth to PositionedOverlay when active', () => {
- const popoverOverlay = mountWithAppProvider(
+ const popoverOverlay = mountWithApp(
', () => {
,
);
- expect(popoverOverlay.find(PositionedOverlay).prop('fullWidth')).toBe(true);
+ expect(popoverOverlay).toContainReactComponent(PositionedOverlay, {
+ fullWidth: true,
+ });
});
it('passes fixed to PositionedOverlay when active', () => {
- const popoverOverlay = mountWithAppProvider(
+ const popoverOverlay = mountWithApp(
', () => {
,
);
- expect(popoverOverlay.find(PositionedOverlay).prop('fixed')).toBe(true);
+ expect(popoverOverlay).toContainReactComponent(PositionedOverlay, {
+ fixed: true,
+ });
});
it('passes preferredPosition and preferredAlignment to PositionedOverlay when active', () => {
- const popoverOverlay = mountWithAppProvider(
+ const popoverOverlay = mountWithApp(
', () => {
,
);
- expect(
- popoverOverlay.find(PositionedOverlay).prop('preferredPosition'),
- ).toBe('above');
- expect(
- popoverOverlay.find(PositionedOverlay).prop('preferredAlignment'),
- ).toBe('right');
+ expect(popoverOverlay).toContainReactComponent(PositionedOverlay, {
+ preferredPosition: 'above',
+ preferredAlignment: 'right',
+ });
});
it('passes default preferredPosition and preferredAlignment to PositionedOverlay when active', () => {
- const popoverOverlay = mountWithAppProvider(
+ const popoverOverlay = mountWithApp(
', () => {
,
);
- expect(
- popoverOverlay.find(PositionedOverlay).prop('preferredPosition'),
- ).toBe('below');
- expect(
- popoverOverlay.find(PositionedOverlay).prop('preferredAlignment'),
- ).toBe('center');
+ expect(popoverOverlay).toContainReactComponent(PositionedOverlay, {
+ preferredPosition: 'below',
+ preferredAlignment: 'center',
+ });
});
it('passes preferInputActivator to PositionedOverlay when false', () => {
- const popoverOverlay = mountWithAppProvider(
+ const popoverOverlay = mountWithApp(
', () => {
,
);
- expect(
- popoverOverlay.find(PositionedOverlay).prop('preferInputActivator'),
- ).toBe(false);
+ expect(popoverOverlay).toContainReactComponent(PositionedOverlay, {
+ preferInputActivator: false,
+ });
});
it('passes zIndexOverride to PositionedOverlay', () => {
@@ -189,7 +183,7 @@ describe('', () => {
});
it("doesn't include a tabindex prop when autofocusTarget is 'none'", () => {
- const popoverOverlay = mountWithAppProvider(
+ const popoverOverlay = mountWithApp(
', () => {
,
);
- expect(
- popoverOverlay.find(PositionedOverlay).prop('preferInputActivator'),
- ).toBe(false);
+ expect(popoverOverlay).toContainReactComponent(PositionedOverlay, {
+ preferInputActivator: false,
+ });
});
it('calls the onClose callback when the escape key is pressed', () => {
const spy = jest.fn();
- mountWithAppProvider(
+ mountWithApp(
', () => {
it('does not call the onClose callback when a descendent HTMLElement is clicked', () => {
const spy = jest.fn();
- const popoverOverlay = mountWithAppProvider(
+ const popoverOverlay = mountWithApp(
', () => {
,
);
- const target = popoverOverlay.find(TextField).find('input').getDOMNode();
+ const target = popoverOverlay.find(TextField)!.find('input')!.domNode;
- const clickEventListener = popoverOverlay
- .find(EventListener)
- .findWhere((node) => node.prop('event') === 'click');
+ const clickEventListener = popoverOverlay.find(EventListener, {
+ event: 'click',
+ })!;
- trigger(clickEventListener, 'handler', {target});
+ clickEventListener.trigger('handler', {target});
expect(spy).not.toHaveBeenCalled();
});
@@ -254,7 +248,7 @@ describe('', () => {
it('does not call the onClose callback when a descendent SVGElement is clicked', () => {
const spy = jest.fn();
- const popoverOverlay = mountWithAppProvider(
+ const popoverOverlay = mountWithApp(
', () => {
,
);
- const target = popoverOverlay
- .find(TextField)
- .find('svg')
- .first()
- .getDOMNode();
+ const target = popoverOverlay.find(TextField)!.find('svg')!.domNode;
- const clickEventListener = popoverOverlay
- .find(EventListener)
- .findWhere((node) => node.prop('event') === 'click');
+ const clickEventListener = popoverOverlay.find(EventListener, {
+ event: 'click',
+ })!;
- trigger(clickEventListener, 'handler', {
+ clickEventListener!.trigger('handler', {
target,
});
-
expect(spy).not.toHaveBeenCalled();
});
it('starts animating in immediately', () => {
- const popoverOverlay = mountWithAppProvider(
+ const popoverOverlay = mountWithApp(
', () => {
);
popoverOverlay.setProps({active: true});
- popoverOverlay.update();
- expect(popoverOverlay.find(PositionedOverlay).prop('classNames')).toMatch(
- /PopoverOverlay-entering/,
- );
+ popoverOverlay.forceUpdate();
+
+ expect(popoverOverlay).toContainReactComponent(PositionedOverlay, {
+ classNames: expect.stringContaining('PopoverOverlay-entering'),
+ });
});
it('does not render after exiting when the component is updated during exit', () => {
jest.useFakeTimers();
- const popoverOverlay = mountWithAppProvider(
+ const popoverOverlay = mountWithApp(
', () => {
);
// Start exiting
- close(popoverOverlay);
-
- // Update before exiting is complete
- triggerSomeUpdate(popoverOverlay);
-
+ popoverOverlay.setProps({active: false});
// Run any timers and a final update for changed state
jest.runOnlyPendingTimers();
- popoverOverlay.update();
- expect(popoverOverlay.find(PositionedOverlay)).toHaveLength(0);
+ popoverOverlay.forceUpdate();
+ expect(popoverOverlay).not.toContainReactComponent(PositionedOverlay);
});
describe('focus', () => {
@@ -351,7 +337,7 @@ describe('', () => {
it('focuses the content on mount', () => {
const focusSpy = jest.spyOn(HTMLElement.prototype, 'focus');
- mountWithAppProvider(
+ mountWithApp(
', () => {
it('focuses the content on mount and prevents scroll in development', () => {
process.env.NODE_ENV = 'development';
const focusSpy = jest.spyOn(HTMLElement.prototype, 'focus');
- mountWithAppProvider(
+ mountWithApp(
', () => {
});
function noop() {}
-
-function close(wrapper: ReactWrapper) {
- wrapper.setProps({active: false});
- wrapper.update();
-}
-
-function triggerSomeUpdate(wrapper: ReactWrapper) {
- wrapper.setProps({fullWidth: true});
- wrapper.update();
-}