Skip to content

Commit 805167c

Browse files
committed
Replace 'Contains'
contains is deprecated and will be removed in the next major version. Use `wrapper.find`, `wrapper.findComponent` or `wrapper.get` instead
1 parent 94c3a44 commit 805167c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+135
-134
lines changed

tests/unit/App.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,10 @@ describe('App', () => {
233233

234234
it('renders a default `Footer` for non-IDE targets', async () => {
235235
const wrapper = createWrapper();
236-
expect(wrapper.contains(Footer)).toBe(true);
236+
expect(wrapper.findComponent(Footer).exists()).toBe(true);
237237

238238
await wrapper.setData({ isTargetIDE: true });
239-
expect(wrapper.contains(Footer)).toBe(false);
239+
expect(wrapper.findComponent(Footer).exists()).toBe(false);
240240
});
241241

242242
it('renders the app-top element', () => {

tests/unit/components/Article/Body.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ describe('Body', () => {
2424

2525
it('renders a `BodyContent`', () => {
2626
const { BodyContent } = Body.components;
27-
expect(wrapper.contains(BodyContent)).toBe(true);
27+
expect(wrapper.findComponent(BodyContent).exists()).toBe(true);
2828
});
2929
});

tests/unit/components/Article/Layouts/FullWidth.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe('FullWidth', () => {
4646
});
4747

4848
it('does not render a `LinkableElement` without headings', () => {
49-
expect(wrapper.contains(LinkableElement)).toBe(false);
49+
expect(wrapper.findComponent(LinkableElement).exists()).toBe(false);
5050
});
5151

5252
describe('with headings', () => {

tests/unit/components/CallToAction.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ describe('CallToAction', () => {
4848
const row = wrapper.findComponent(Row);
4949
expect(row.exists()).toBe(true);
5050

51-
expect(row.contains(LeftColumn)).toBe(true);
52-
expect(row.contains(RightColumn)).toBe(true);
51+
expect(row.findComponent(LeftColumn).exists()).toBe(true);
52+
expect(row.findComponent(RightColumn).exists()).toBe(true);
5353
});
5454

5555
describe('LeftColumn', () => {

tests/unit/components/ContentNode.spec.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ describe('ContentNode', () => {
128128
const figure = wrapper.findComponent(Figure);
129129
expect(figure.exists()).toBe(true);
130130
expect(figure.props('anchor')).toBe(metadata.anchor);
131-
expect(figure.contains(CodeListing)).toBe(true);
131+
expect(figure.findComponent(CodeListing).exists()).toBe(true);
132132

133133
const caption = figure.find(Caption);
134134
expect(caption.exists()).toBe(true);
135135
expect(caption.props('title')).toBe(metadata.title);
136-
expect(caption.contains('p')).toBe(true);
136+
expect(caption.find('p').exists()).toBe(true);
137137
expect(caption.text()).toContain('blah');
138138
});
139139
});
@@ -733,11 +733,11 @@ describe('ContentNode', () => {
733733
const figure = wrapper.findComponent(Figure);
734734
expect(figure.exists()).toBe(true);
735735
expect(figure.props('anchor')).toBe(metadata.anchor);
736-
expect(figure.contains(InlineImage)).toBe(true);
736+
expect(figure.findComponent(InlineImage).exists()).toBe(true);
737737

738738
const caption = wrapper.findComponent(Caption);
739739
expect(caption.exists()).toBe(true);
740-
expect(caption.contains('p')).toBe(true);
740+
expect(caption.find('p').exists()).toBe(true);
741741
expect(caption.props('title')).toBe(metadata.title);
742742
expect(caption.text()).toContain('blah');
743743
});
@@ -758,11 +758,11 @@ describe('ContentNode', () => {
758758
const figure = wrapper.findComponent(Figure);
759759
expect(figure.exists()).toBe(true);
760760
expect(figure.props('anchor')).toBeFalsy();
761-
expect(figure.contains(InlineImage)).toBe(true);
761+
expect(figure.findComponent(InlineImage).exists()).toBe(true);
762762

763763
const caption = wrapper.findComponent(Caption);
764764
expect(caption.exists()).toBe(true);
765-
expect(caption.contains('p')).toBe(true);
765+
expect(caption.find('p').exists()).toBe(true);
766766
expect(caption.props('title')).toBeFalsy();
767767
expect(caption.props('position')).toBe('trailing');
768768
expect(caption.text()).toContain('blah');
@@ -815,7 +815,7 @@ describe('ContentNode', () => {
815815
const figure = wrapper.findComponent(Figure);
816816
expect(figure.exists()).toBe(true);
817817
expect(figure.props('anchor')).toBe('foo-figure');
818-
expect(figure.contains(InlineImage)).toBe(true);
818+
expect(figure.findComponent(InlineImage).exists()).toBe(true);
819819

820820
expect(wrapper.findComponent(Caption).exists()).toBe(false);
821821
});
@@ -910,11 +910,11 @@ describe('ContentNode', () => {
910910
const figure = wrapper.findComponent(Figure);
911911
expect(figure.exists()).toBe(true);
912912
expect(figure.props('anchor')).toBe('foo');
913-
expect(figure.contains(BlockVideo)).toBe(true);
913+
expect(figure.findComponent(BlockVideo).exists()).toBe(true);
914914

915915
const caption = wrapper.findComponent(Caption);
916916
expect(caption.exists()).toBe(true);
917-
expect(caption.contains('p')).toBe(true);
917+
expect(caption.find('p').exists()).toBe(true);
918918
expect(caption.props('title')).toBe(metadata.title);
919919
expect(caption.props('position')).toBe('trailing');
920920
expect(caption.text()).toContain('blah');
@@ -936,11 +936,11 @@ describe('ContentNode', () => {
936936
const figure = wrapper.findComponent(Figure);
937937
expect(figure.exists()).toBe(true);
938938
expect(figure.props('anchor')).toBeFalsy();
939-
expect(figure.contains(BlockVideo)).toBe(true);
939+
expect(figure.findComponent(BlockVideo).exists()).toBe(true);
940940

941941
const caption = wrapper.findComponent(Caption);
942942
expect(caption.exists()).toBe(true);
943-
expect(caption.contains('p')).toBe(true);
943+
expect(caption.find('p').exists()).toBe(true);
944944
expect(caption.props('title')).toBeFalsy();
945945
expect(caption.props('position')).toBe('trailing');
946946
expect(caption.text()).toContain('blah');
@@ -1377,7 +1377,7 @@ describe('ContentNode', () => {
13771377
const table = wrapper.findComponent('.content').find(Table);
13781378
expect(table.exists()).toBe(true);
13791379
expect(table.props('spanned')).toBe(false);
1380-
expect(table.contains('thead')).toBe(false);
1380+
expect(table.find('thead').exists()).toBe(false);
13811381
expect(table.findAll('tbody tr').length).toBe(2);
13821382
expect(table.findAll('tbody tr td').length).toBe(4);
13831383
});
@@ -1415,7 +1415,7 @@ describe('ContentNode', () => {
14151415
});
14161416
const table = wrapper.findComponent('.content').find(Table);
14171417
expect(table.exists()).toBe(true);
1418-
expect(table.contains('thead')).toBe(false);
1418+
expect(table.find('thead').exists()).toBe(false);
14191419
expect(table.findAll('tbody tr th[scope="row"]').length).toBe(2);
14201420
expect(table.findAll('tbody tr td').length).toBe(2);
14211421
});
@@ -1445,7 +1445,7 @@ describe('ContentNode', () => {
14451445
expect(caption.props('title')).toBe(metadata.title);
14461446
expect(caption.props('position')).toBe('leading');
14471447
expect(caption.props('tag')).toBe('caption');
1448-
expect(caption.contains('p')).toBe(true);
1448+
expect(caption.find('p').exists()).toBe(true);
14491449
expect(caption.text()).toContain('blah');
14501450
});
14511451

tests/unit/components/ContentNode/CollapsibleCodeListing.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('CollapsibleCodeListing', () => {
5050
expect(wrapper.is('.collapsible-code-listing')).toBe(true);
5151
const pre = wrapper.findComponent('pre');
5252
expect(pre.exists()).toBe(true);
53-
expect(pre.contains(CodeBlock)).toBe(true);
53+
expect(pre.findComponent(CodeBlock).exists()).toBe(true);
5454
});
5555

5656
it('renders code in .code-line elements', () => {

tests/unit/components/ContentNode/Table.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('Table', () => {
1919
expect(wrapper.is('.table-wrapper')).toBe(true);
2020
const table = wrapper.findComponent('table');
2121
expect(table.exists()).toBe(true);
22-
expect(table.contains('tbody tr td')).toBe(true);
22+
expect(table.find('tbody tr td').exists()).toBe(true);
2323
});
2424

2525
it('renders a table with `spanned` class', () => {

tests/unit/components/DocumentationLayout.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ describe('DocumentationLayout', () => {
524524

525525
it('does not render a `Nav`', () => {
526526
wrapper = createWrapper({ provide: provideWithIDETarget });
527-
expect(wrapper.contains(Nav)).toBe(false);
527+
expect(wrapper.findComponent(Nav).exists()).toBe(false);
528528
});
529529

530530
it('does not render a sidebar', () => {

tests/unit/components/DocumentationTopic.spec.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -651,24 +651,24 @@ describe('DocumentationTopic', () => {
651651

652652
it('does not render a `PrimaryContent` column when passed undefined as PrimaryContent', async () => {
653653
await wrapper.setProps({ primaryContentSections: undefined });
654-
expect(wrapper.contains(PrimaryContent)).toBe(false);
654+
expect(wrapper.findComponent(PrimaryContent).exists()).toBe(false);
655655
});
656656

657657
it('does not render a `PrimaryContent` column when passed empty an PrimaryContent', async () => {
658658
await wrapper.setProps({ primaryContentSections: [] });
659-
expect(wrapper.contains(PrimaryContent)).toBe(false);
659+
expect(wrapper.findComponent(PrimaryContent).exists()).toBe(false);
660660
});
661661

662662
it('does not render a `PrimaryContent` column when passed empty an PrimaryContent & no `ViewMore` link', async () => {
663663
await wrapper.setProps({ primaryContentSections: [], enableMinimized: true });
664-
expect(wrapper.contains(PrimaryContent)).toBe(true); // ViewMore link is present
664+
expect(wrapper.findComponent(PrimaryContent).exists()).toBe(true); // ViewMore link is present
665665

666666
await wrapper.setProps({
667667
primaryContentSections: [],
668668
enableMinimized: true,
669669
hasNoExpandedDocumentation: true,
670670
});
671-
expect(wrapper.contains(PrimaryContent)).toBe(false); // no ViewMore link
671+
expect(wrapper.findComponent(PrimaryContent).exists()).toBe(false); // no ViewMore link
672672
});
673673

674674
it('render a `PrimaryContent` column when passed empty an PrimaryContent but has otherDeclarations', async () => {
@@ -678,7 +678,8 @@ describe('DocumentationTopic', () => {
678678
hasOtherDeclSection,
679679
],
680680
});
681-
expect(wrapper.contains(PrimaryContent)).toBe(true); // has otherDeclarations dropdown
681+
expect(wrapper.findComponent(PrimaryContent).exists())
682+
.toBe(true); // has otherDeclarations dropdown
682683
});
683684

684685
it('renders `ViewMore` if `enableMinimized`', async () => {
@@ -756,7 +757,7 @@ describe('DocumentationTopic', () => {
756757
});
757758

758759
it('renders a deprecated `Aside` when deprecated', async () => {
759-
expect(wrapper.contains(Aside)).toBe(false);
760+
expect(wrapper.findComponent(Aside).exists()).toBe(false);
760761
await wrapper.setProps({ deprecationSummary });
761762

762763
const aside = wrapper.findComponent(Aside);
@@ -769,7 +770,7 @@ describe('DocumentationTopic', () => {
769770
});
770771

771772
it('renders a note `Aside` when download button is not available', async () => {
772-
expect(wrapper.contains(Aside)).toBe(false);
773+
expect(wrapper.findComponent(Aside).exists()).toBe(false);
773774
await wrapper.setProps({ downloadNotAvailableSummary });
774775

775776
const aside = wrapper.findComponent(Aside);
@@ -782,15 +783,15 @@ describe('DocumentationTopic', () => {
782783
});
783784

784785
it('renders a `DownloadButton` if there is sample code to download', async () => {
785-
expect(wrapper.contains(DownloadButton)).toBe(false);
786+
expect(wrapper.findComponent(DownloadButton).exists()).toBe(false);
786787
await wrapper.setProps({ sampleCodeDownload });
787-
expect(wrapper.contains(DownloadButton)).toBe(true);
788+
expect(wrapper.findComponent(DownloadButton).exists()).toBe(true);
788789
});
789790

790791
it('renders a `RequirementMetadata` if the symbol is required', async () => {
791-
expect(wrapper.contains(RequirementMetadata)).toBe(false);
792+
expect(wrapper.findComponent(RequirementMetadata).exists()).toBe(false);
792793
await wrapper.setProps({ isRequirement: true });
793-
expect(wrapper.contains(RequirementMetadata)).toBe(true);
794+
expect(wrapper.findComponent(RequirementMetadata).exists()).toBe(true);
794795
});
795796

796797
it('renders a `Availability` with platforms data', async () => {
@@ -898,7 +899,7 @@ describe('DocumentationTopic', () => {
898899
});
899900

900901
it('renders `Topics` if there are topic sections, passing the `topicSectionsStyle` over', async () => {
901-
expect(wrapper.contains(Topics)).toBe(false);
902+
expect(wrapper.findComponent(Topics).exists()).toBe(false);
902903

903904
const topicSections = [
904905
{
@@ -937,7 +938,7 @@ describe('DocumentationTopic', () => {
937938
});
938939

939940
it('renders `SeeAlso` if there are see also sections', async () => {
940-
expect(wrapper.contains(SeeAlso)).toBe(false);
941+
expect(wrapper.findComponent(SeeAlso).exists()).toBe(false);
941942

942943
const seeAlsoSections = [
943944
{
@@ -964,7 +965,7 @@ describe('DocumentationTopic', () => {
964965
});
965966

966967
it('renders `Relationships` if there are relationship sections', async () => {
967-
expect(wrapper.contains(Relationships)).toBe(false);
968+
expect(wrapper.findComponent(Relationships).exists()).toBe(false);
968969

969970
const relationshipsSections = [
970971
{
@@ -1022,7 +1023,7 @@ describe('DocumentationTopic', () => {
10221023
});
10231024

10241025
it('renders `DefaultImplementations` if there are default implementation sections', async () => {
1025-
expect(wrapper.contains(DefaultImplementations)).toBe(false);
1026+
expect(wrapper.findComponent(DefaultImplementations).exists()).toBe(false);
10261027

10271028
const defaultImplementationsSections = [
10281029
{
@@ -1098,7 +1099,7 @@ describe('DocumentationTopic', () => {
10981099
store: mockStore,
10991100
},
11001101
});
1101-
expect(wrapper.findComponent(DocumentationHero).contains('.above-title')).toBe(true);
1102+
expect(wrapper.findComponent(DocumentationHero).find('.above-title').exists()).toBe(true);
11021103
});
11031104

11041105
it('renders content in the `above-hero-content` slot', () => {
@@ -1114,7 +1115,7 @@ describe('DocumentationTopic', () => {
11141115
store: mockStore,
11151116
},
11161117
});
1117-
expect(wrapper.contains('.above-hero-content')).toBe(true);
1118+
expect(wrapper.find('.above-hero-content').exists()).toBe(true);
11181119
});
11191120

11201121
it('renders `OnThisPageNav` component, if enabled via prop', async () => {

tests/unit/components/DocumentationTopic/DocumentationNav.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ describe('DocumentationNav', () => {
156156
});
157157

158158
it('does not render a `LanguageToggle` when there is no swift nor objc path', async () => {
159-
expect(wrapper.contains(LanguageToggle)).toBe(true);
159+
expect(wrapper.findComponent(LanguageToggle).exists()).toBe(true);
160160
await wrapper.setProps({ swiftPath: null, objcPath: null });
161-
expect(wrapper.contains(LanguageToggle)).toBe(false);
161+
expect(wrapper.findComponent(LanguageToggle).exists()).toBe(false);
162162
});
163163

164164
it('exposes a `menu-items` slot ', () => {

0 commit comments

Comments
 (0)