From e483bd4d49692b37bfd77b9a5bc39ec12b20724c Mon Sep 17 00:00:00 2001 From: Eli White Date: Wed, 20 Nov 2019 18:06:57 -0800 Subject: [PATCH] Add Jest snapshot tests to TextInput Summary: $title Changelog: [Internal] Reviewed By: yungsters Differential Revision: D18536359 fbshipit-source-id: 382c81c094c0ae28ec3e203cb0726bdbccf755dc --- .../TextInput/__tests__/TextInput-test.js | 15 +++- .../__snapshots__/TextInput-test.js.snap | 69 +++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap diff --git a/Libraries/Components/TextInput/__tests__/TextInput-test.js b/Libraries/Components/TextInput/__tests__/TextInput-test.js index c8a10e4e7d..8eb8a47718 100644 --- a/Libraries/Components/TextInput/__tests__/TextInput-test.js +++ b/Libraries/Components/TextInput/__tests__/TextInput-test.js @@ -18,7 +18,10 @@ const ReactNative = require('../../../Renderer/shims/ReactNative'); import Component from '@reactions/component'; -const {enter} = require('../../../Utilities/ReactNativeTestTools'); +const { + enter, + expectRendersMatchingSnapshot, +} = require('../../../Utilities/ReactNativeTestTools'); jest.unmock('../TextInput'); @@ -150,4 +153,14 @@ describe('TextInput tests', () => { expect(textInputRe2.current.isFocused()).toBe(true); expect(TextInput.State.currentlyFocusedField()).toBe(inputTag2); }); + + it('should render as expected', () => { + expectRendersMatchingSnapshot( + 'TextInput', + () => , + () => { + jest.dontMock('../TextInput'); + }, + ); + }); }); diff --git a/Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap b/Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap new file mode 100644 index 0000000000..1bdc43330e --- /dev/null +++ b/Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap @@ -0,0 +1,69 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`TextInput tests should render as expected: should deep render when mocked (please verify output manually) 1`] = ` + +`; + +exports[`TextInput tests should render as expected: should deep render when not mocked (please verify output manually) 1`] = ` + +`; + +exports[`TextInput tests should render as expected: should shallow render as when mocked 1`] = ` + +`; + +exports[`TextInput tests should render as expected: should shallow render as when not mocked 1`] = ` + +`;