From 12fb58859661550fda95817374fbc3f775bd63dc Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Mon, 18 Sep 2017 19:23:35 -0700 Subject: [PATCH] Simplify View snapshot testing --- .../__snapshots__/index-test.js.snap | 31 ++++++------------- src/components/View/__tests__/index-test.js | 17 +++++----- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/src/components/View/__tests__/__snapshots__/index-test.js.snap b/src/components/View/__tests__/__snapshots__/index-test.js.snap index c4632a42..f7c10dbe 100644 --- a/src/components/View/__tests__/__snapshots__/index-test.js.snap +++ b/src/components/View/__tests__/__snapshots__/index-test.js.snap @@ -1,29 +1,16 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/View prop "hitSlop" handles partial offsets 1`] = ` -
- -
+Object { + "top": "-10px", +} `; exports[`components/View prop "hitSlop" renders a span with negative position offsets 1`] = ` -
- -
-`; - -exports[`components/View prop "pointerEvents" 1`] = ` -
+Object { + "bottom": "-10px", + "left": "-5px", + "right": "-5px", + "top": "-10px", +} `; diff --git a/src/components/View/__tests__/index-test.js b/src/components/View/__tests__/index-test.js index 92252606..781da280 100644 --- a/src/components/View/__tests__/index-test.js +++ b/src/components/View/__tests__/index-test.js @@ -1,7 +1,7 @@ /* eslint-env jasmine, jest */ import React from 'react'; -import { render, shallow } from 'enzyme'; +import { shallow } from 'enzyme'; import View from '../'; describe('components/View', () => { @@ -39,18 +39,21 @@ describe('components/View', () => { describe('prop "hitSlop"', () => { it('renders a span with negative position offsets', () => { - const component = render(); - expect(component).toMatchSnapshot(); + const component = shallow(); + const span = component.find('span'); + expect(span.length).toBe(1); + expect(span.prop('style')).toMatchSnapshot(); }); it('handles partial offsets', () => { - const component = render(); - expect(component).toMatchSnapshot(); + const component = shallow(); + const span = component.find('span'); + expect(span.prop('style')).toMatchSnapshot(); }); }); test('prop "pointerEvents"', () => { - const component = render(); - expect(component).toMatchSnapshot(); + const component = shallow(); + expect(component.prop('className').indexOf('pointerEvents') > -1).toBe(true); }); });