11import React from 'react' ;
2- // eslint-disable-next-line no-restricted-imports
3- import { mountWithAppProvider } from 'test-utilities/legacy' ;
2+ import { mountWithApp } from 'test-utilities' ;
43import {
54 Layout ,
65 Card ,
@@ -13,68 +12,76 @@ import {SkeletonPage} from '../SkeletonPage';
1312
1413describe ( '<SkeletonPage />' , ( ) => {
1514 it ( 'renders its children' , ( ) => {
16- const children = (
17- < Layout >
18- < Layout . Section >
19- < Card sectioned >
20- < SkeletonBodyText />
21- </ Card >
22- < Card sectioned title = "Variants" >
23- < SkeletonBodyText />
24- </ Card >
25- </ Layout . Section >
26- </ Layout >
27- ) ;
15+ const Children = ( ) => {
16+ return (
17+ < Layout >
18+ < Layout . Section >
19+ < Card sectioned >
20+ < SkeletonBodyText />
21+ </ Card >
22+ < Card sectioned title = "Variants" >
23+ < SkeletonBodyText />
24+ </ Card >
25+ </ Layout . Section >
26+ </ Layout >
27+ ) ;
28+ } ;
2829
29- const skeletonPage = mountWithAppProvider (
30- < SkeletonPage title = "Products" > { children } </ SkeletonPage > ,
30+ const skeletonPage = mountWithApp (
31+ < SkeletonPage title = "Products" >
32+ < Children />
33+ </ SkeletonPage > ,
3134 ) ;
32- expect ( skeletonPage . contains ( children ) ) . toBe ( true ) ;
35+ expect ( skeletonPage ) . toContainReactComponent ( Children ) ;
3336 } ) ;
3437
3538 describe ( 'title' , ( ) => {
3639 it ( 'renders an h1 with the Title class when title is defined' , ( ) => {
37- const skeletonPage = mountWithAppProvider (
38- < SkeletonPage title = "Products" /> ,
39- ) ;
40+ const skeletonPage = mountWithApp ( < SkeletonPage title = "Products" /> ) ;
4041
41- expect ( skeletonPage . find ( 'h1. Title' ) ) . toHaveLength ( 1 ) ;
42- expect ( skeletonPage . find ( DisplayText ) ) . toHaveLength ( 0 ) ;
42+ expect ( skeletonPage ) . toContainReactComponent ( 'h1' , { className : ' Title'} ) ;
43+ expect ( skeletonPage ) . not . toContainReactComponent ( DisplayText ) ;
4344 } ) ;
4445
4546 it ( 'renders SkeletonTitle when a title not defined' , ( ) => {
46- const skeletonPage = mountWithAppProvider ( < SkeletonPage /> ) ;
47+ const skeletonPage = mountWithApp ( < SkeletonPage /> ) ;
4748
48- expect ( skeletonPage . find ( 'h1.Title' ) ) . toHaveLength ( 0 ) ;
49- expect ( skeletonPage . find ( '.SkeletonTitle' ) ) . toHaveLength ( 1 ) ;
49+ expect ( skeletonPage ) . not . toContainReactComponent ( 'h1' , {
50+ className : 'Title' ,
51+ } ) ;
52+ expect ( skeletonPage ) . toContainReactComponent ( 'div' , {
53+ className : 'SkeletonTitle' ,
54+ } ) ;
5055 } ) ;
5156
5257 it ( 'renders SkeletonTitle when title is an empty string' , ( ) => {
53- const skeletonPage = mountWithAppProvider ( < SkeletonPage title = "" /> ) ;
58+ const skeletonPage = mountWithApp ( < SkeletonPage title = "" /> ) ;
5459
55- expect ( skeletonPage . find ( 'h1.Title' ) ) . toHaveLength ( 0 ) ;
56- expect ( skeletonPage . find ( '.SkeletonTitle' ) ) . toHaveLength ( 1 ) ;
60+ expect ( skeletonPage ) . not . toContainReactComponent ( 'h1' , {
61+ className : 'Title' ,
62+ } ) ;
63+ expect ( skeletonPage ) . toContainReactComponent ( 'div' , {
64+ className : 'SkeletonTitle' ,
65+ } ) ;
5766 } ) ;
5867 } ) ;
5968
6069 it ( 'renders the provided number of secondary actions as SkeletonBodyText' , ( ) => {
61- const skeletonPage = mountWithAppProvider (
62- < SkeletonPage secondaryActions = { 3 } /> ,
63- ) ;
64- expect ( skeletonPage . find ( SkeletonBodyText ) ) . toHaveLength ( 3 ) ;
70+ const skeletonPage = mountWithApp ( < SkeletonPage secondaryActions = { 3 } /> ) ;
71+ expect ( skeletonPage ) . toContainReactComponentTimes ( SkeletonBodyText , 3 ) ;
6572 } ) ;
6673
6774 it ( 'renders breadcrumbs' , ( ) => {
68- const skeletonPage = mountWithAppProvider ( < SkeletonPage breadcrumbs /> ) ;
69- expect ( skeletonPage . find ( SkeletonBodyText ) ) . toHaveLength ( 1 ) ;
75+ const skeletonPage = mountWithApp ( < SkeletonPage breadcrumbs /> ) ;
76+ expect ( skeletonPage ) . toContainReactComponent ( SkeletonBodyText ) ;
7077 } ) ;
7178
7279 describe ( 'primaryAction' , ( ) => {
7380 it ( 'renders SkeletonDisplayText if true' , ( ) => {
74- const skeletonPage = mountWithAppProvider (
81+ const skeletonPage = mountWithApp (
7582 < SkeletonPage title = "Title" primaryAction /> ,
7683 ) ;
77- expect ( skeletonPage . find ( SkeletonDisplayText ) ) . toHaveLength ( 1 ) ;
84+ expect ( skeletonPage ) . toContainReactComponent ( SkeletonDisplayText ) ;
7885 } ) ;
7986 } ) ;
8087} ) ;
0 commit comments