11import { mount } from 'enzyme' ;
22import wait from 'waait' ;
3+ import toJSON from 'enzyme-to-json' ;
34import Nav from '../components/Nav' ;
4- import { CURRENT_USER_QUERY } from '../components/User'
5+ import { CURRENT_USER_QUERY } from '../components/User' ;
56import { MockedProvider } from 'react-apollo/test-utils' ;
67import { fakeUser , fakeCartItem } from '../lib/testUtils' ;
7- import toJSON from 'enzyme-to-json' ;
88
99const notSignedInMocks = [
1010 {
@@ -19,14 +19,15 @@ const signedInMocks = [
1919 result : { data : { me : fakeUser ( ) } } ,
2020 } ,
2121] ;
22+
2223const signedInMocksWithCartItems = [
2324 {
2425 request : { query : CURRENT_USER_QUERY } ,
2526 result : {
2627 data : {
2728 me : {
2829 ...fakeUser ( ) ,
29- cart : [ fakeCartItem ( ) , fakeCartItem ( ) , fakeCartItem ( ) ]
30+ cart : [ fakeCartItem ( ) , fakeCartItem ( ) , fakeCartItem ( ) ] ,
3031 } ,
3132 } ,
3233 } ,
@@ -42,26 +43,23 @@ describe('<Nav/>', () => {
4243 ) ;
4344 await wait ( ) ;
4445 wrapper . update ( ) ;
45-
46- const nav = wrapper . find ( '[data-test="nav"]' ) ;
47-
48- expect ( toJSON ( nav ) ) . toMatchSnapshot ( )
46+ // console.log(wrapper.debug());
47+ const nav = wrapper . find ( 'ul[data-test="nav"]' ) ;
48+ expect ( toJSON ( nav ) ) . toMatchSnapshot ( ) ;
4949 } ) ;
5050
5151 it ( 'renders full nav when signed in' , async ( ) => {
5252 const wrapper = mount (
53- < MockedProvider mocks = { signedInMocksWithCartItems } >
53+ < MockedProvider mocks = { signedInMocks } >
5454 < Nav />
5555 </ MockedProvider >
56- )
56+ ) ;
5757 await wait ( ) ;
5858 wrapper . update ( ) ;
59- console . log ( wrapper . debug ( ) ) ;
6059 const nav = wrapper . find ( 'ul[data-test="nav"]' ) ;
6160 expect ( nav . children ( ) . length ) . toBe ( 6 ) ;
6261 expect ( nav . text ( ) ) . toContain ( 'Sign Out' ) ;
63- // expect(toJSON(nav)).toMatchSnapshot()
64- } )
62+ } ) ;
6563
6664 it ( 'renders the amount of items in the cart' , async ( ) => {
6765 const wrapper = mount (
@@ -74,5 +72,5 @@ describe('<Nav/>', () => {
7472 const nav = wrapper . find ( '[data-test="nav"]' ) ;
7573 const count = nav . find ( 'div.count' ) ;
7674 expect ( toJSON ( count ) ) . toMatchSnapshot ( ) ;
77- } )
75+ } ) ;
7876} ) ;
0 commit comments