+
{descriptionMarkup}
)}
diff --git a/src/components/Layout/tests/Layout.test.tsx b/src/components/Layout/tests/Layout.test.tsx
index 51035235184..eaedfc6339b 100644
--- a/src/components/Layout/tests/Layout.test.tsx
+++ b/src/components/Layout/tests/Layout.test.tsx
@@ -1,103 +1,113 @@
import React from 'react';
-// eslint-disable-next-line no-restricted-imports
-import {findByTestID, mountWithAppProvider} from 'test-utilities/legacy';
+import {mountWithApp} from 'test-utilities';
+import {TextContainer} from 'components/TextContainer';
+import {Heading} from 'components/Heading';
+import styles from 'Layout.scss';
import {Section} from '../components';
import {Layout} from '../Layout';
describe('
', () => {
it('renders children', () => {
- const layout = mountWithAppProvider(
+ const layout = mountWithApp(
,
);
- expect(layout.find(MyComponent).exists()).toBe(true);
+ expect(layout).toContainReactComponent(MyComponent);
});
it('renders children wrapped in a section', () => {
- const layout = mountWithAppProvider(
+ const layout = mountWithApp(
,
);
- const section = layout.find(Section);
- expect(section.exists()).toBe(true);
- expect(section.find(MyComponent).exists()).toBe(true);
+ expect(layout).toContainReactComponent(Section);
+ expect(layout.find(Section)).toContainReactComponent(MyComponent);
});
describe('
', () => {
it('renders children', () => {
- const annotatedSection = mountWithAppProvider(
+ const annotatedSection = mountWithApp(
,
);
- expect(annotatedSection.find(MyComponent).exists()).toBe(true);
+ expect(annotatedSection).toContainReactComponent(MyComponent);
});
it('renders a title', () => {
const title = 'Store details';
- const annotatedSection = mountWithAppProvider(
-
,
+ const annotatedSection = mountWithApp(
+
,
);
-
- expect(findByTestID(annotatedSection, 'AnnotationTitle').text()).toBe(
+ expect(annotatedSection.find(Heading, {id: 'someId'})).toContainReactText(
title,
);
});
it('renders a description as a string', () => {
const description = 'A good description of this section';
- const annotatedSection = mountWithAppProvider(
+ const annotatedSection = mountWithApp(
,
);
- expect(
- findByTestID(annotatedSection, 'AnnotationDescription').text(),
- ).toBe(description);
+ const annotedDescriptionTextContainer = annotatedSection.find(
+ TextContainer,
+ )!;
+
+ expect(annotedDescriptionTextContainer.find('div')).toContainReactText(
+ description,
+ );
});
it('renders a description as a node', () => {
- const annotatedSection = mountWithAppProvider(
+ const annotatedSection = mountWithApp(
} />,
);
- const annotatedDescription = findByTestID(
- annotatedSection,
- 'AnnotationDescription',
- );
- expect(annotatedDescription.find(MyComponent).exists()).toBe(true);
+ const annotedDescriptionTextContainer = annotatedSection.find(
+ TextContainer,
+ )!;
+
+ expect(annotedDescriptionTextContainer).toContainReactComponent(
+ MyComponent,
+ );
});
it('does not render an empty description node', () => {
- const annotatedSection = mountWithAppProvider(
+ const annotatedSection = mountWithApp(
,
);
- const description = findByTestID(
- annotatedSection,
- 'AnnotationDescription',
- );
- expect(description.exists()).toBe(false);
+ const annotedDescriptionTextContainer = annotatedSection.find(
+ TextContainer,
+ )!;
+
+ expect(annotatedSection).toContainReactComponent(TextContainer);
+ expect(annotedDescriptionTextContainer).not.toContainReactComponent(
+ 'div',
+ {
+ className: expect.stringContaining(styles.AnnotationDescription),
+ },
+ );
});
it('passes through an ID for deeplinking', () => {
- const layout = mountWithAppProvider(
+ const layout = mountWithApp(
,
);
- const section = layout.find('#MySection');
-
- expect(section.exists()).toBe(true);
+ expect(layout).toContainReactComponent(Heading, {id: 'MySection'});
});
});
});
diff --git a/src/components/MediaCard/tests/MediaCard.test.tsx b/src/components/MediaCard/tests/MediaCard.test.tsx
index 7aec2496986..58f7a737851 100644
--- a/src/components/MediaCard/tests/MediaCard.test.tsx
+++ b/src/components/MediaCard/tests/MediaCard.test.tsx
@@ -1,8 +1,6 @@
import React from 'react';
import {Heading, Popover, Button, ActionList, Badge} from 'components';
import {mountWithApp} from 'test-utilities';
-// eslint-disable-next-line no-restricted-imports
-import {mountWithAppProvider} from 'test-utilities/legacy';
import {MediaCard} from '../MediaCard';
@@ -33,14 +31,12 @@ describe('
', () => {
{badgeString}
);
- const videoCard = mountWithAppProvider(
- ,
- );
+ const videoCard = mountWithApp();
- const headerMarkup = videoCard.find('h2');
+ const headerMarkup = videoCard.find('h2')!;
- expect(headerMarkup.text()).toContain(titleString);
- expect(headerMarkup.find('Badge').text()).toBe(badgeString);
+ expect(headerMarkup.find(Badge)).toContainReactText(badgeString);
+ expect(headerMarkup).toContainReactText(titleString);
});
it('renders the description as a paragraph', () => {