From f142f312915795e33ceb550619ae092a5603dd2d Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Tue, 7 Feb 2017 11:08:26 +0200 Subject: [PATCH] Separate shallow and deep render for snapshot tests --- src/components/BookingInfo/BookingInfo.test.js | 4 ++-- src/components/FilterPanel/FilterPanel.test.js | 10 ++-------- src/components/HeroSection/HeroSection.test.js | 4 ++-- src/components/ListingCard/ListingCard.test.js | 10 ++-------- .../ListingCardSmall/ListingCardSmall.test.js | 4 ++-- src/components/MapPanel/MapPanel.test.js | 10 ++-------- src/components/Menu/Menu.test.js | 4 ++-- .../OrderDetailsPanel/OrderDetailsPanel.test.js | 10 ++-------- .../OrderDiscussionPanel/OrderDiscussionPanel.test.js | 10 ++-------- .../SearchResultsPanel/SearchResultsPanel.test.js | 10 ++-------- .../AuthenticationPage/AuthenticationPage.test.js | 4 ++-- .../ChangeAccountPasswordForm.test.js | 4 ++-- .../ChangePasswordForm/ChangePasswordForm.test.js | 4 ++-- src/containers/CheckoutPage/CheckoutPage.test.js | 10 ++-------- .../ContactDetailsPage/ContactDetailsPage.test.js | 4 ++-- src/containers/EditProfilePage/EditProfilePage.test.js | 4 ++-- src/containers/HeroSearchForm/HeroSearchForm.test.js | 4 ++-- src/containers/InboxPage/InboxPage.test.js | 4 ++-- src/containers/LandingPage/LandingPage.test.js | 8 ++------ src/containers/ListingPage/ListingPage.test.js | 10 ++-------- src/containers/LoginForm/LoginForm.test.js | 4 ++-- .../ManageListingsPage/ManageListingsPage.test.js | 4 ++-- src/containers/NotFoundPage/NotFoundPage.test.js | 4 ++-- src/containers/OrderPage/OrderPage.test.js | 10 ++-------- .../PasswordChangePage/PasswordChangePage.test.js | 4 ++-- .../PasswordForgottenForm.test.js | 4 ++-- .../PasswordForgottenPage.test.js | 4 ++-- .../PayoutPreferencesPage.test.js | 4 ++-- src/containers/ProfilePage/ProfilePage.test.js | 4 ++-- .../SalesConversationPage.test.js | 4 ++-- src/containers/SearchPage/SearchPage.test.js | 10 ++-------- src/containers/SecurityPage/SecurityPage.test.js | 4 ++-- src/containers/SignUpForm/SignUpForm.test.js | 4 ++-- src/util/test-helpers.js | 10 ++++++++-- 34 files changed, 74 insertions(+), 132 deletions(-) diff --git a/src/components/BookingInfo/BookingInfo.test.js b/src/components/BookingInfo/BookingInfo.test.js index 139d535a..342e2409 100644 --- a/src/components/BookingInfo/BookingInfo.test.js +++ b/src/components/BookingInfo/BookingInfo.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderDeep } from '../../util/test-helpers'; import BookingInfo from './BookingInfo'; describe('BookingInfo', () => { it('matches snapshot', () => { - const tree = renderTree( + const tree = renderDeep( { it('matches snapshot', () => { - const tree = renderTree( - - - , - ); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/components/HeroSection/HeroSection.test.js b/src/components/HeroSection/HeroSection.test.js index 5e2e1d80..25e550d1 100644 --- a/src/components/HeroSection/HeroSection.test.js +++ b/src/components/HeroSection/HeroSection.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderDeep } from '../../util/test-helpers'; import HeroSection from './HeroSection'; describe('HeroSection', () => { it('matches snapshot', () => { - const tree = renderTree( + const tree = renderDeep( test , diff --git a/src/components/ListingCard/ListingCard.test.js b/src/components/ListingCard/ListingCard.test.js index 58835d92..052894c5 100644 --- a/src/components/ListingCard/ListingCard.test.js +++ b/src/components/ListingCard/ListingCard.test.js @@ -1,7 +1,5 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; -import { RoutesProvider } from '../../components'; -import routesConfiguration from '../../routesConfiguration'; +import { renderShallow } from '../../util/test-helpers'; import ListingCard from './ListingCard'; describe('ListingCard', () => { @@ -19,11 +17,7 @@ describe('ListingCard', () => { review: { rating: '4' }, }, }; - const tree = renderTree( - - - , - ); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/components/ListingCardSmall/ListingCardSmall.test.js b/src/components/ListingCardSmall/ListingCardSmall.test.js index ca8ff0f0..7b4f74d8 100644 --- a/src/components/ListingCardSmall/ListingCardSmall.test.js +++ b/src/components/ListingCardSmall/ListingCardSmall.test.js @@ -1,5 +1,5 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderDeep } from '../../util/test-helpers'; import { RoutesProvider } from '../../components'; import routesConfiguration from '../../routesConfiguration'; import ListingCardSmall from './ListingCardSmall'; @@ -19,7 +19,7 @@ describe('ListingCardSmall', () => { review: { rating: '4' }, }, }; - const tree = renderTree( + const tree = renderDeep( , diff --git a/src/components/MapPanel/MapPanel.test.js b/src/components/MapPanel/MapPanel.test.js index 6d3c2b45..95787f3e 100644 --- a/src/components/MapPanel/MapPanel.test.js +++ b/src/components/MapPanel/MapPanel.test.js @@ -1,16 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; -import { RoutesProvider } from '../../components'; -import routesConfiguration from '../../routesConfiguration'; +import { renderShallow } from '../../util/test-helpers'; import MapPanel from './MapPanel'; describe('MapPanel', () => { it('matches snapshot', () => { - const tree = renderTree( - - - , - ); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/components/Menu/Menu.test.js b/src/components/Menu/Menu.test.js index 2d0ff5b3..06729bd7 100644 --- a/src/components/Menu/Menu.test.js +++ b/src/components/Menu/Menu.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderDeep } from '../../util/test-helpers'; import Menu from './Menu'; describe('Menu', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderDeep(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/components/OrderDetailsPanel/OrderDetailsPanel.test.js b/src/components/OrderDetailsPanel/OrderDetailsPanel.test.js index 9c20623b..ee0ae9e4 100644 --- a/src/components/OrderDetailsPanel/OrderDetailsPanel.test.js +++ b/src/components/OrderDetailsPanel/OrderDetailsPanel.test.js @@ -1,8 +1,6 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import OrderDetailsPanel from './OrderDetailsPanel.js'; -import { RoutesProvider } from '../../components'; -import routesConfiguration from '../../routesConfiguration'; describe('OrderDetailsPanel', () => { it('matches snapshot', () => { @@ -23,11 +21,7 @@ describe('OrderDetailsPanel', () => { }, confirmationCode: 'some-test-confirmation-code', }; - const tree = renderTree( - - - , - ); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/components/OrderDiscussionPanel/OrderDiscussionPanel.test.js b/src/components/OrderDiscussionPanel/OrderDiscussionPanel.test.js index 197fbfdc..486ebff5 100644 --- a/src/components/OrderDiscussionPanel/OrderDiscussionPanel.test.js +++ b/src/components/OrderDiscussionPanel/OrderDiscussionPanel.test.js @@ -1,16 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderDeep } from '../../util/test-helpers'; import OrderDiscussionPanel from './OrderDiscussionPanel.js'; -import { RoutesProvider } from '../../components'; -import routesConfiguration from '../../routesConfiguration'; describe('OrderDiscussionPanel', () => { it('matches snapshot', () => { - const tree = renderTree( - - - , - ); + const tree = renderDeep(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/components/SearchResultsPanel/SearchResultsPanel.test.js b/src/components/SearchResultsPanel/SearchResultsPanel.test.js index 2788349d..72d1d372 100644 --- a/src/components/SearchResultsPanel/SearchResultsPanel.test.js +++ b/src/components/SearchResultsPanel/SearchResultsPanel.test.js @@ -1,16 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; -import { RoutesProvider } from '../../components'; -import routesConfiguration from '../../routesConfiguration'; +import { renderShallow } from '../../util/test-helpers'; import SearchResultsPanel from './SearchResultsPanel'; describe('SearchResultsPanel', () => { it('matches snapshot', () => { - const tree = renderTree( - - - , - ); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/AuthenticationPage/AuthenticationPage.test.js b/src/containers/AuthenticationPage/AuthenticationPage.test.js index e3e92cac..88b4b079 100644 --- a/src/containers/AuthenticationPage/AuthenticationPage.test.js +++ b/src/containers/AuthenticationPage/AuthenticationPage.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import AuthenticationPage from './AuthenticationPage'; describe('AuthenticationPage', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/ChangeAccountPasswordForm/ChangeAccountPasswordForm.test.js b/src/containers/ChangeAccountPasswordForm/ChangeAccountPasswordForm.test.js index f8efbbbb..3e07b350 100644 --- a/src/containers/ChangeAccountPasswordForm/ChangeAccountPasswordForm.test.js +++ b/src/containers/ChangeAccountPasswordForm/ChangeAccountPasswordForm.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderDeep } from '../../util/test-helpers'; import ChangeAccountPasswordForm from './ChangeAccountPasswordForm'; describe('ChangeAccountPasswordForm', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderDeep(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/ChangePasswordForm/ChangePasswordForm.test.js b/src/containers/ChangePasswordForm/ChangePasswordForm.test.js index a0f3c073..e936ab66 100644 --- a/src/containers/ChangePasswordForm/ChangePasswordForm.test.js +++ b/src/containers/ChangePasswordForm/ChangePasswordForm.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderDeep } from '../../util/test-helpers'; import ChangePasswordForm from './ChangePasswordForm'; describe('ChangePasswordForm', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderDeep(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/CheckoutPage/CheckoutPage.test.js b/src/containers/CheckoutPage/CheckoutPage.test.js index b1c8a7f1..6046922e 100644 --- a/src/containers/CheckoutPage/CheckoutPage.test.js +++ b/src/containers/CheckoutPage/CheckoutPage.test.js @@ -1,16 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import CheckoutPage from './CheckoutPage'; -import { RoutesProvider } from '../../components'; -import routesConfiguration from '../../routesConfiguration'; describe('CheckoutPage', () => { it('matches snapshot', () => { - const tree = renderTree( - - - , - ); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/ContactDetailsPage/ContactDetailsPage.test.js b/src/containers/ContactDetailsPage/ContactDetailsPage.test.js index df6ef1eb..bb5c018e 100644 --- a/src/containers/ContactDetailsPage/ContactDetailsPage.test.js +++ b/src/containers/ContactDetailsPage/ContactDetailsPage.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import ContactDetailsPage from './ContactDetailsPage'; describe('ContactDetailsPage', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/EditProfilePage/EditProfilePage.test.js b/src/containers/EditProfilePage/EditProfilePage.test.js index 9af3ab30..7fa4f23d 100644 --- a/src/containers/EditProfilePage/EditProfilePage.test.js +++ b/src/containers/EditProfilePage/EditProfilePage.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import EditProfilePage from './EditProfilePage'; describe('EditProfilePage', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/HeroSearchForm/HeroSearchForm.test.js b/src/containers/HeroSearchForm/HeroSearchForm.test.js index 90ea07ba..31580c1f 100644 --- a/src/containers/HeroSearchForm/HeroSearchForm.test.js +++ b/src/containers/HeroSearchForm/HeroSearchForm.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderDeep } from '../../util/test-helpers'; import HeroSearchForm from './HeroSearchForm'; describe('HeroSearchForm', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderDeep(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/InboxPage/InboxPage.test.js b/src/containers/InboxPage/InboxPage.test.js index e19435ce..0b1dcbcc 100644 --- a/src/containers/InboxPage/InboxPage.test.js +++ b/src/containers/InboxPage/InboxPage.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import InboxPage from './InboxPage'; describe('InboxPage', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/LandingPage/LandingPage.test.js b/src/containers/LandingPage/LandingPage.test.js index a34ca3b5..9e46c19e 100644 --- a/src/containers/LandingPage/LandingPage.test.js +++ b/src/containers/LandingPage/LandingPage.test.js @@ -1,16 +1,12 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import { LandingPageComponent } from './LandingPage'; import { RoutesProvider } from '../../components'; import routesConfiguration from '../../routesConfiguration'; describe('LandingPage', () => { it('matches snapshot', () => { - const tree = renderTree( - - v} /> - , - ); + const tree = renderShallow( v} />); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/ListingPage/ListingPage.test.js b/src/containers/ListingPage/ListingPage.test.js index f56a89d9..9b7c1e52 100644 --- a/src/containers/ListingPage/ListingPage.test.js +++ b/src/containers/ListingPage/ListingPage.test.js @@ -1,16 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; -import { RoutesProvider } from '../../components'; -import routesConfiguration from '../../routesConfiguration'; +import { renderShallow } from '../../util/test-helpers'; import ListingPage from './ListingPage'; describe('ListingPage', () => { it('matches snapshot', () => { - const tree = renderTree( - - - , - ); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/LoginForm/LoginForm.test.js b/src/containers/LoginForm/LoginForm.test.js index 08854d6b..bffa3a3b 100644 --- a/src/containers/LoginForm/LoginForm.test.js +++ b/src/containers/LoginForm/LoginForm.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderDeep } from '../../util/test-helpers'; import LoginForm from './LoginForm'; describe('LoginForm', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderDeep(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/ManageListingsPage/ManageListingsPage.test.js b/src/containers/ManageListingsPage/ManageListingsPage.test.js index 78e0e447..61bdb1d2 100644 --- a/src/containers/ManageListingsPage/ManageListingsPage.test.js +++ b/src/containers/ManageListingsPage/ManageListingsPage.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import ManageListingsPage from './ManageListingsPage'; describe('ManageListingsPage', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/NotFoundPage/NotFoundPage.test.js b/src/containers/NotFoundPage/NotFoundPage.test.js index d4bbc959..b34e1278 100644 --- a/src/containers/NotFoundPage/NotFoundPage.test.js +++ b/src/containers/NotFoundPage/NotFoundPage.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import NotFoundPage from './NotFoundPage'; describe('NotFoundPage', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/OrderPage/OrderPage.test.js b/src/containers/OrderPage/OrderPage.test.js index 51c19c26..50888c38 100644 --- a/src/containers/OrderPage/OrderPage.test.js +++ b/src/containers/OrderPage/OrderPage.test.js @@ -1,16 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import OrderPage from './OrderPage'; -import { RoutesProvider } from '../../components'; -import routesConfiguration from '../../routesConfiguration'; describe('OrderPage', () => { it('matches snapshot', () => { - const tree = renderTree( - - - , - ); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/PasswordChangePage/PasswordChangePage.test.js b/src/containers/PasswordChangePage/PasswordChangePage.test.js index a978b3e3..ed8f2d16 100644 --- a/src/containers/PasswordChangePage/PasswordChangePage.test.js +++ b/src/containers/PasswordChangePage/PasswordChangePage.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import PasswordChangePage from './PasswordChangePage'; describe('PasswordChangePage', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/PasswordForgottenForm/PasswordForgottenForm.test.js b/src/containers/PasswordForgottenForm/PasswordForgottenForm.test.js index 3197b48b..64f14cd0 100644 --- a/src/containers/PasswordForgottenForm/PasswordForgottenForm.test.js +++ b/src/containers/PasswordForgottenForm/PasswordForgottenForm.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderDeep } from '../../util/test-helpers'; import PasswordForgottenForm from './PasswordForgottenForm'; describe('PasswordForgottenForm', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderDeep(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/PasswordForgottenPage/PasswordForgottenPage.test.js b/src/containers/PasswordForgottenPage/PasswordForgottenPage.test.js index 714442f1..adf1e258 100644 --- a/src/containers/PasswordForgottenPage/PasswordForgottenPage.test.js +++ b/src/containers/PasswordForgottenPage/PasswordForgottenPage.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import PasswordForgottenPage from './PasswordForgottenPage'; describe('PasswordForgottenPage', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/PayoutPreferencesPage/PayoutPreferencesPage.test.js b/src/containers/PayoutPreferencesPage/PayoutPreferencesPage.test.js index 497a5455..2b8f0c03 100644 --- a/src/containers/PayoutPreferencesPage/PayoutPreferencesPage.test.js +++ b/src/containers/PayoutPreferencesPage/PayoutPreferencesPage.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import PayoutPreferencesPage from './PayoutPreferencesPage'; describe('PayoutPreferencesPage', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/ProfilePage/ProfilePage.test.js b/src/containers/ProfilePage/ProfilePage.test.js index 382836b0..5e36535a 100644 --- a/src/containers/ProfilePage/ProfilePage.test.js +++ b/src/containers/ProfilePage/ProfilePage.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import ProfilePage from './ProfilePage'; describe('ProfilePage', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/SalesConversationPage/SalesConversationPage.test.js b/src/containers/SalesConversationPage/SalesConversationPage.test.js index d9689ad4..4070e593 100644 --- a/src/containers/SalesConversationPage/SalesConversationPage.test.js +++ b/src/containers/SalesConversationPage/SalesConversationPage.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import SalesConversationPage from './SalesConversationPage'; describe('SalesConversationPage', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/SearchPage/SearchPage.test.js b/src/containers/SearchPage/SearchPage.test.js index 1a5c878a..de8aa864 100644 --- a/src/containers/SearchPage/SearchPage.test.js +++ b/src/containers/SearchPage/SearchPage.test.js @@ -1,17 +1,11 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import { SearchPageComponent } from './SearchPage'; import reducer, { ADD_FILTER, addFilter, initialState } from './SearchPage.ducks'; -import { RoutesProvider } from '../../components'; -import routesConfiguration from '../../routesConfiguration'; describe('SearchPageComponent', () => { it('matches snapshot', () => { - const tree = renderTree( - - v} /> - , - ); + const tree = renderShallow( v} />); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/SecurityPage/SecurityPage.test.js b/src/containers/SecurityPage/SecurityPage.test.js index 78a137c3..a8199842 100644 --- a/src/containers/SecurityPage/SecurityPage.test.js +++ b/src/containers/SecurityPage/SecurityPage.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderShallow } from '../../util/test-helpers'; import SecurityPage from './SecurityPage'; describe('SecurityPage', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/SignUpForm/SignUpForm.test.js b/src/containers/SignUpForm/SignUpForm.test.js index accf8b1c..a901d213 100644 --- a/src/containers/SignUpForm/SignUpForm.test.js +++ b/src/containers/SignUpForm/SignUpForm.test.js @@ -1,10 +1,10 @@ import React from 'react'; -import { renderTree } from '../../util/test-helpers'; +import { renderDeep } from '../../util/test-helpers'; import SignUpForm from './SignUpForm'; describe('SignUpForm', () => { it('matches snapshot', () => { - const tree = renderTree(); + const tree = renderDeep(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/util/test-helpers.js b/src/util/test-helpers.js index 7d40dda4..5c1a6818 100644 --- a/src/util/test-helpers.js +++ b/src/util/test-helpers.js @@ -1,5 +1,7 @@ import React from 'react'; import renderer from 'react-test-renderer'; +import { shallow } from 'enzyme'; +import toJson from 'enzyme-to-json'; import { IntlProvider } from 'react-intl'; import { BrowserRouter } from 'react-router'; import { Provider } from 'react-redux'; @@ -18,10 +20,14 @@ export const TestProvider = props => { ); }; -export const renderTree = children => { +export const renderShallow = component => { + return toJson(shallow(component)); +}; + +export const renderDeep = component => { const comp = renderer.create( - {children} + {component} , ); return comp.toJSON();