diff --git a/UNRELEASED.md b/UNRELEASED.md
index 14fd511edb0..606f8d849a4 100644
--- a/UNRELEASED.md
+++ b/UNRELEASED.md
@@ -66,5 +66,6 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f
- Modernized tests for Message, Menu, Search, SearchDismissOverlay, SearchField, UserMenu and TopBar components. ([#4311](https://github.com/Shopify/polaris-react/pull/4311))
- Modernized tests for MediaCard, and Layout components ([#4393](https://github.com/Shopify/polaris-react/pull/4393))
- Modernized tests for Image and Icon components ([#4418](https://github.com/Shopify/polaris-react/pull/4418))
+- Modernized tests for EventListener and EmptySearch components([#4423](https://github.com/Shopify/polaris-react/pull/4423))
### Deprecations
diff --git a/src/components/EmptySearchResult/tests/EmptySearchResult.test.tsx b/src/components/EmptySearchResult/tests/EmptySearchResult.test.tsx
index 6d96090356b..3eee57d044b 100644
--- a/src/components/EmptySearchResult/tests/EmptySearchResult.test.tsx
+++ b/src/components/EmptySearchResult/tests/EmptySearchResult.test.tsx
@@ -1,6 +1,5 @@
import React from 'react';
-// eslint-disable-next-line no-restricted-imports
-import {mountWithAppProvider} from 'test-utilities/legacy';
+import {mountWithApp} from 'test-utilities';
import {DisplayText, TextStyle} from 'components';
import {EmptySearchResult} from '../EmptySearchResult';
@@ -8,37 +7,35 @@ import {emptySearch} from '../illustrations';
describe('', () => {
it("displays the title with style 'Display Small'", () => {
- const wrapper = mountWithAppProvider();
+ const wrapper = mountWithApp();
const displaySmalls = wrapper.findWhere(
(wrap) => wrap.is(DisplayText) && wrap.prop('size') === 'small',
);
- expect(displaySmalls).toHaveLength(1);
- expect(displaySmalls.first().text()).toBe('Foo');
+
+ expect(wrapper).toContainReactComponent(DisplayText, {size: 'small'});
+ expect(displaySmalls).toContainReactText('Foo');
});
it("displays the description with style 'Body Subdued'", () => {
- const wrapper = mountWithAppProvider(
+ const wrapper = mountWithApp(
,
);
const subdued = wrapper.findWhere(
(wrap) => wrap.is(TextStyle) && wrap.prop('variation') === 'subdued',
);
- expect(subdued).toHaveLength(1);
- expect(subdued.first().text()).toBe('Bar');
+ expect(wrapper).toContainReactComponent(TextStyle, {variation: 'subdued'});
+ expect(subdued).toContainReactText('Bar');
});
it('does not display an image when `withIllustration` is false', () => {
- const wrapper = mountWithAppProvider();
- const images = wrapper.find('img');
- expect(images).toHaveLength(0);
+ const wrapper = mountWithApp();
+ expect(wrapper).not.toContainReactComponent('img');
});
it('displays the illustration when `withIllustration` is true', () => {
- const wrapper = mountWithAppProvider(
+ const wrapper = mountWithApp(
,
);
- const images = wrapper.find('img');
- expect(images).toHaveLength(1);
- expect(images.first().prop('src')).toBe(emptySearch);
+ expect(wrapper).toContainReactComponentTimes('img', 1, {src: emptySearch});
});
});
diff --git a/src/components/EventListener/tests/EventListener.test.tsx b/src/components/EventListener/tests/EventListener.test.tsx
index ecc793c4919..17f59019d54 100644
--- a/src/components/EventListener/tests/EventListener.test.tsx
+++ b/src/components/EventListener/tests/EventListener.test.tsx
@@ -1,27 +1,26 @@
import React from 'react';
-// eslint-disable-next-line no-restricted-imports
-import {mountWithAppProvider} from 'test-utilities/legacy';
+import {mountWithApp} from 'test-utilities';
import {EventListener} from '../EventListener';
describe('', () => {
it('calls handler when the resize event is fired', () => {
const spy = jest.fn();
- mountWithAppProvider();
+ mountWithApp();
window.dispatchEvent(new Event('resize'));
expect(spy).toHaveBeenCalled();
});
it('does not call handler when a different event is fired', () => {
const spy = jest.fn();
- mountWithAppProvider();
+ mountWithApp();
window.dispatchEvent(new Event('resize'));
expect(spy).not.toHaveBeenCalled();
});
it('removes listener on update', () => {
const spy = jest.fn();
- const eventListener = mountWithAppProvider(
+ const eventListener = mountWithApp(
,
);
eventListener.setProps({event: 'scroll', handler: noop});
@@ -31,9 +30,7 @@ describe('', () => {
it('removes listener when unmounted', () => {
const spy = jest.fn();
- mountWithAppProvider(
- ,
- ).unmount();
+ mountWithApp().unmount();
window.dispatchEvent(new Event('resize'));
expect(spy).not.toHaveBeenCalled();
});