11import * as React from 'react'
2- import renderer from 'react-test-renderer '
2+ import { render } from '@testing-library/react '
33import { MemoryRouter } from 'react-router-dom'
44
55import * as BreadCrumbs from './'
66
77describe ( 'components/BreadCrumbs' , ( ) => {
88 describe ( 'Segment' , ( ) => {
99 it ( 'should render EMPTY' , ( ) => {
10- const tree = renderer . create ( < BreadCrumbs . Segment /> ) . toJSON ( )
11- expect ( tree ) . toMatchSnapshot ( )
10+ const { container } = render ( < BreadCrumbs . Segment /> )
11+ expect ( container ) . toMatchSnapshot ( )
1212 } )
1313 it ( 'should render label' , ( ) => {
14- const tree = renderer . create ( < BreadCrumbs . Segment label = "Lorem ipsum" /> ) . toJSON ( )
15- expect ( tree ) . toMatchSnapshot ( )
14+ const { container } = render ( < BreadCrumbs . Segment label = "Lorem ipsum" /> )
15+ expect ( container ) . toMatchSnapshot ( )
1616 } )
1717 it ( 'should render link' , ( ) => {
18- const tree = renderer
19- . create (
20- < MemoryRouter >
21- < BreadCrumbs . Segment label = "A" to = "/a" />
22- </ MemoryRouter > ,
23- )
24- . toJSON ( )
25- expect ( tree ) . toMatchSnapshot ( )
18+ const { container } = render (
19+ < MemoryRouter >
20+ < BreadCrumbs . Segment label = "A" to = "/a" />
21+ </ MemoryRouter > ,
22+ )
23+ expect ( container ) . toMatchSnapshot ( )
2624 } )
2725 } )
2826 describe ( 'render' , ( ) => {
2927 it ( 'basic breadcrumbs' , ( ) => {
3028 const crumbs = BreadCrumbs . getCrumbs ( 'aa a/bb-b/c/d_d' , ( x ) => x , 'ROOT' )
31- const tree = renderer
32- . create ( < MemoryRouter > { BreadCrumbs . render ( crumbs ) } </ MemoryRouter > )
33- . toJSON ( )
34- expect ( tree ) . toMatchSnapshot ( )
29+ const { container } = render (
30+ < MemoryRouter > { BreadCrumbs . render ( crumbs ) } </ MemoryRouter > ,
31+ )
32+ expect ( container ) . toMatchSnapshot ( )
3533 } )
3634 it ( 'and transform links' , ( ) => {
3735 const crumbs = BreadCrumbs . getCrumbs ( 'a/b' , ( x ) => x , 'ROOT' )
3836 const getLinkProps = ( { to } : { to ?: string } ) => ( {
3937 href : `https://quiltdata.com/${ to || '' } ` ,
4038 } )
41- const tree = renderer
42- . create (
43- < MemoryRouter > { BreadCrumbs . render ( crumbs , { getLinkProps } ) } </ MemoryRouter > ,
44- )
45- . toJSON ( )
46- expect ( tree ) . toMatchSnapshot ( )
39+ const { container } = render (
40+ < MemoryRouter > { BreadCrumbs . render ( crumbs , { getLinkProps } ) } </ MemoryRouter > ,
41+ )
42+ expect ( container ) . toMatchSnapshot ( )
4743 } )
4844 it ( 'and make links for every crumb' , ( ) => {
4945 const crumbs = BreadCrumbs . getCrumbs ( 'a/b' , ( x ) => x , 'ROOT' , { tailLink : true } )
5046 const getLinkProps = ( { to } : { to ?: string } ) => ( {
5147 href : `https://quiltdata.com/${ to || '' } ` ,
5248 } )
53- const tree = renderer
54- . create (
55- < MemoryRouter > { BreadCrumbs . render ( crumbs , { getLinkProps } ) } </ MemoryRouter > ,
56- )
57- . toJSON ( )
58- expect ( tree ) . toMatchSnapshot ( )
49+ const { container } = render (
50+ < MemoryRouter > { BreadCrumbs . render ( crumbs , { getLinkProps } ) } </ MemoryRouter > ,
51+ )
52+ expect ( container ) . toMatchSnapshot ( )
5953 } )
6054 it ( 'and end with separator' , ( ) => {
6155 const crumbs = BreadCrumbs . getCrumbs ( 'a/b' , ( x ) => x , 'ROOT' , {
@@ -65,19 +59,17 @@ describe('components/BreadCrumbs', () => {
6559 const getLinkProps = ( { to } : { to ?: string } ) => ( {
6660 href : `https://quiltdata.com/${ to || '' } ` ,
6761 } )
68- const tree = renderer
69- . create (
70- < MemoryRouter > { BreadCrumbs . render ( crumbs , { getLinkProps } ) } </ MemoryRouter > ,
71- )
72- . toJSON ( )
73- expect ( tree ) . toMatchSnapshot ( )
62+ const { container } = render (
63+ < MemoryRouter > { BreadCrumbs . render ( crumbs , { getLinkProps } ) } </ MemoryRouter > ,
64+ )
65+ expect ( container ) . toMatchSnapshot ( )
7466 } )
7567 it ( 'without root label' , ( ) => {
7668 const crumbs = BreadCrumbs . getCrumbs ( 'a/b/c' , ( x ) => x )
77- const tree = renderer
78- . create ( < MemoryRouter > { BreadCrumbs . render ( crumbs ) } </ MemoryRouter > )
79- . toJSON ( )
80- expect ( tree ) . toMatchSnapshot ( )
69+ const { container } = render (
70+ < MemoryRouter > { BreadCrumbs . render ( crumbs ) } </ MemoryRouter > ,
71+ )
72+ expect ( container ) . toMatchSnapshot ( )
8173 } )
8274 } )
8375 it ( 'copyWithoutSpaces' , ( ) => {
0 commit comments