From 58dc36b0c688de909fd1dcbb7804e991052124ed Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sun, 24 Mar 2019 12:57:53 -0400 Subject: [PATCH] Updating index page tests to use react-testing-library --- src/pages/__snapshots__/index.test.js.snap | 124 ++++++++------------- src/pages/index.test.js | 17 ++- 2 files changed, 60 insertions(+), 81 deletions(-) diff --git a/src/pages/__snapshots__/index.test.js.snap b/src/pages/__snapshots__/index.test.js.snap index b2aaaeb..10c9f0b 100644 --- a/src/pages/__snapshots__/index.test.js.snap +++ b/src/pages/__snapshots__/index.test.js.snap @@ -1,89 +1,61 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Index Page rendering 1`] = ` - - + - - + - + `; exports[`Index Page rendering with an expression on the URL 1`] = ` - - + - - + - + `; diff --git a/src/pages/index.test.js b/src/pages/index.test.js index ede26f7..ca1dfda 100644 --- a/src/pages/index.test.js +++ b/src/pages/index.test.js @@ -1,5 +1,12 @@ +jest.mock('components/Metadata', () => + require('__mocks__/component-mock')('components/Metadata')); +jest.mock('components/Message', () => + require('__mocks__/component-mock')('components/Message')); +jest.mock('components/App', () => + require('__mocks__/component-mock')('components/App')); + import React from 'react'; -import { shallow } from 'enzyme'; +import { render } from 'react-testing-library'; import { IndexPage } from 'pages/index'; @@ -18,19 +25,19 @@ const queryResult = { describe('Index Page', () => { test('rendering', () => { - const component = shallow( + const { asFragment } = render( ); - expect(component).toMatchSnapshot(); + expect(asFragment()).toMatchSnapshot(); }); test('rendering with an expression on the URL', () => { - const component = shallow( + const { asFragment } = render( ); - expect(component).toMatchSnapshot(); + expect(asFragment()).toMatchSnapshot(); }); });