From 0d512a1a4db8fdf4872a8b1651cc9b4eecfc3bcc Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sun, 24 Mar 2019 14:16:07 -0400 Subject: [PATCH] Updating Metadata to use react-testing-library --- .../Metadata/__snapshots__/test.js.snap | 58 ++++++++++--------- src/components/Metadata/test.js | 18 ++++-- 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/src/components/Metadata/__snapshots__/test.js.snap b/src/components/Metadata/__snapshots__/test.js.snap index 7f02a3f..ca8e43b 100644 --- a/src/components/Metadata/__snapshots__/test.js.snap +++ b/src/components/Metadata/__snapshots__/test.js.snap @@ -1,37 +1,39 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Metadata rendering 1`] = ` - + - - Regexper - - +}" + > + + Regexper + + + `; exports[`Metadata rendering with a title and description 1`] = ` - + - - Regexper - Testing - - - +}" + > + + Regexper - Testing + + + + `; diff --git a/src/components/Metadata/test.js b/src/components/Metadata/test.js index b7f3cdf..89c4d29 100644 --- a/src/components/Metadata/test.js +++ b/src/components/Metadata/test.js @@ -1,5 +1,13 @@ +jest.mock('react-helmet', () => { + const helmet = jest.requireActual('react-helmet'); + return { + ...helmet, + Helmet: require('__mocks__/component-mock').buildMock(helmet.Helmet) + }; +}); + import React from 'react'; -import { shallow } from 'enzyme'; +import { render } from 'react-testing-library'; import { Metadata } from 'components/Metadata'; @@ -9,19 +17,19 @@ const commonProps = { describe('Metadata', () => { test('rendering', () => { - const component = shallow( + const { asFragment } = render( ); - expect(component).toMatchSnapshot(); + expect(asFragment()).toMatchSnapshot(); }); test('rendering with a title and description', () => { - const component = shallow( + const { asFragment } = render( ); - expect(component).toMatchSnapshot(); + expect(asFragment()).toMatchSnapshot(); }); });