From a7e063b01cde8afd5d78a2f9ef988cb7811ef9f4 Mon Sep 17 00:00:00 2001 From: Matt Pace Date: Fri, 10 Feb 2017 18:59:42 -0500 Subject: [PATCH] Add active component test --- client/__tests__/ActiveComponent-test.js | 46 ++++++++++++++++++++++++ package.json | 2 ++ 2 files changed, 48 insertions(+) create mode 100644 client/__tests__/ActiveComponent-test.js diff --git a/client/__tests__/ActiveComponent-test.js b/client/__tests__/ActiveComponent-test.js new file mode 100644 index 00000000..2b0f2ab5 --- /dev/null +++ b/client/__tests__/ActiveComponent-test.js @@ -0,0 +1,46 @@ +import 'jsdom-global/register' + +import React from 'react' +import renderer from 'react-test-renderer' +import {mount} from 'enzyme'; + +import MainLayout from '../components/MainLayout' + +const FirstActiveView = () => { + return ( +

First active view

+ ) +} + +const SecondActiveView = () => { + return ( +

Second active view

+ ) +} + +test('Renders main layout', () => { + const tree = renderer.create( + + ).toJSON(); + expect(tree).toMatchSnapshot(); +}); + +test('Renders active views correctly', () => { + const firstTree = mount( + + ) + + const secondTree = mount( + + ) + + expect(firstTree).not.toBe(secondTree) + expect(firstTree.contains(

First active view

)).toBeTruthy() + expect(secondTree.contains(

Second active view

)).toBeTruthy() +}) diff --git a/package.json b/package.json index 14feaaa6..27b203d1 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,8 @@ }, "devDependencies": { "jest": "^17.0.3", + "jsdom": "9.10.0", + "jsdom-global": "2.1.1", "react-native-babel-jest": "^0.2.0" } }