From 782dc940a66bdd8df338e1e8fdac25171ae09fd2 Mon Sep 17 00:00:00 2001 From: Brandon Carroll Date: Thu, 25 Apr 2019 12:08:59 -0700 Subject: [PATCH] add snapshots for mocked and unmocked components part 2 (#24593) Summary: Per conversation with TheSavior, in #24538, this adds snapshot tests for more components. Shallow and deep snapshots are included. [General] [Added] - Snapshots Pull Request resolved: https://github.com/facebook/react-native/pull/24593 Differential Revision: D15082831 Pulled By: TheSavior fbshipit-source-id: bc7f27317e2fd0bad133f4ba4d81996d08a12c44 --- .../__tests__/MaskedViewIOS-test.js | 81 ++++++++++++++ .../__snapshots__/MaskedViewIOS-test.js.snap | 77 +++++++++++++ .../Picker/__tests__/Picker-test.js | 63 +++++++++++ .../__snapshots__/Picker-test.js.snap | 101 ++++++++++++++++++ .../__tests__/ProgressBarAndroid-test.js | 52 +++++++++ .../ProgressBarAndroid-test.js.snap | 33 ++++++ .../__tests__/ProgressViewIOS-test.js | 43 ++++++++ .../ProgressViewIOS-test.js.snap | 41 +++++++ Libraries/Modal/__tests__/Modal-test.js | 60 +++++++++++ .../__snapshots__/Modal-test.js.snap | 79 ++++++++++++++ 10 files changed, 630 insertions(+) create mode 100644 Libraries/Components/MaskedView/__tests__/MaskedViewIOS-test.js create mode 100644 Libraries/Components/MaskedView/__tests__/__snapshots__/MaskedViewIOS-test.js.snap create mode 100644 Libraries/Components/Picker/__tests__/Picker-test.js create mode 100644 Libraries/Components/Picker/__tests__/__snapshots__/Picker-test.js.snap create mode 100644 Libraries/Components/ProgressBarAndroid/__tests__/ProgressBarAndroid-test.js create mode 100644 Libraries/Components/ProgressBarAndroid/__tests__/__snapshots__/ProgressBarAndroid-test.js.snap create mode 100644 Libraries/Components/ProgressViewIOS/__tests__/ProgressViewIOS-test.js create mode 100644 Libraries/Components/ProgressViewIOS/__tests__/__snapshots__/ProgressViewIOS-test.js.snap create mode 100644 Libraries/Modal/__tests__/Modal-test.js create mode 100644 Libraries/Modal/__tests__/__snapshots__/Modal-test.js.snap diff --git a/Libraries/Components/MaskedView/__tests__/MaskedViewIOS-test.js b/Libraries/Components/MaskedView/__tests__/MaskedViewIOS-test.js new file mode 100644 index 00000000000..01abd518ca7 --- /dev/null +++ b/Libraries/Components/MaskedView/__tests__/MaskedViewIOS-test.js @@ -0,0 +1,81 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @emails oncall+react_native + * @flow + */ + +'use strict'; + +const React = require('React'); +const Text = require('Text'); +const View = require('View'); +const MaskedViewIOS = require('MaskedViewIOS'); + +const render = require('../../../../jest/renderer'); + +describe('', () => { + it('should render as when mocked', () => { + const instance = render.create( + + Basic Mask + + }> + + , + ); + expect(instance).toMatchSnapshot(); + }); + + it('should shallow render as when mocked', () => { + const output = render.shallow( + + Basic Mask + + }> + + , + ); + expect(output).toMatchSnapshot(); + }); + + it('should shallow render as when not mocked', () => { + jest.dontMock('MaskedViewIOS'); + + const output = render.shallow( + + Basic Mask + + }> + + , + ); + expect(output).toMatchSnapshot(); + }); + + it('should render as when not mocked', () => { + jest.dontMock('MaskedViewIOS'); + + const instance = render.create( + + Basic Mask + + }> + + , + ); + expect(instance).toMatchSnapshot(); + }); +}); diff --git a/Libraries/Components/MaskedView/__tests__/__snapshots__/MaskedViewIOS-test.js.snap b/Libraries/Components/MaskedView/__tests__/__snapshots__/MaskedViewIOS-test.js.snap new file mode 100644 index 00000000000..528e33e0e49 --- /dev/null +++ b/Libraries/Components/MaskedView/__tests__/__snapshots__/MaskedViewIOS-test.js.snap @@ -0,0 +1,77 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` should render as when mocked 1`] = ` + + + + + Basic Mask + + + + + +`; + +exports[` should render as when not mocked 1`] = ` + + + + + Basic Mask + + + + + +`; + +exports[` should shallow render as when mocked 1`] = ` + + + Basic Mask + + + } +> + + +`; + +exports[` should shallow render as when not mocked 1`] = ` + + + Basic Mask + + + } +> + + +`; diff --git a/Libraries/Components/Picker/__tests__/Picker-test.js b/Libraries/Components/Picker/__tests__/Picker-test.js new file mode 100644 index 00000000000..05d66379949 --- /dev/null +++ b/Libraries/Components/Picker/__tests__/Picker-test.js @@ -0,0 +1,63 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @emails oncall+react_native + * @flow + */ + +'use strict'; + +const React = require('React'); +const Picker = require('../Picker'); + +const render = require('../../../../jest/renderer'); + +describe('', () => { + it('should render as when mocked', () => { + const instance = render.create( + + + + , + ); + expect(instance).toMatchSnapshot(); + }); + + it('should shallow render as when mocked', () => { + const output = render.shallow( + + + + , + ); + expect(output).toMatchSnapshot(); + }); + + it('should shallow render as when not mocked', () => { + jest.dontMock('Picker'); + + const output = render.shallow( + + + + , + ); + expect(output).toMatchSnapshot(); + }); + + it('should render as when not mocked', () => { + jest.dontMock('Picker'); + + const instance = render.create( + + + + , + ); + expect(instance).toMatchSnapshot(); + }); +}); diff --git a/Libraries/Components/Picker/__tests__/__snapshots__/Picker-test.js.snap b/Libraries/Components/Picker/__tests__/__snapshots__/Picker-test.js.snap new file mode 100644 index 00000000000..00b157697b7 --- /dev/null +++ b/Libraries/Components/Picker/__tests__/__snapshots__/Picker-test.js.snap @@ -0,0 +1,101 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` should render as when mocked 1`] = ` + + + +`; + +exports[` should render as when not mocked 1`] = ` + + + +`; + +exports[` should shallow render as when mocked 1`] = ` + + + + +`; + +exports[` should shallow render as when not mocked 1`] = ` + + + + +`; diff --git a/Libraries/Components/ProgressBarAndroid/__tests__/ProgressBarAndroid-test.js b/Libraries/Components/ProgressBarAndroid/__tests__/ProgressBarAndroid-test.js new file mode 100644 index 00000000000..7cdaad5ed46 --- /dev/null +++ b/Libraries/Components/ProgressBarAndroid/__tests__/ProgressBarAndroid-test.js @@ -0,0 +1,52 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @emails oncall+react_native + * @flow + */ + +'use strict'; + +const React = require('React'); +// $FlowFixMe +const ProgressBarAndroid = require('../ProgressBarAndroid.android'); + +const render = require('../../../../jest/renderer'); + +describe('', () => { + it('should render as when mocked', () => { + const instance = render.create( + , + ); + expect(instance).toMatchSnapshot(); + }); + + it('should shallow render as when mocked', () => { + const output = render.shallow( + , + ); + expect(output).toMatchSnapshot(); + }); + + it('should shallow render as when not mocked', () => { + jest.dontMock('ProgressBarAndroid'); + + const output = render.shallow( + , + ); + expect(output).toMatchSnapshot(); + }); + + it('should render as when not mocked', () => { + jest.dontMock('ProgressBarAndroid'); + + const instance = render.create( + , + ); + expect(instance).toMatchSnapshot(); + }); +}); diff --git a/Libraries/Components/ProgressBarAndroid/__tests__/__snapshots__/ProgressBarAndroid-test.js.snap b/Libraries/Components/ProgressBarAndroid/__tests__/__snapshots__/ProgressBarAndroid-test.js.snap new file mode 100644 index 00000000000..7d45cab7a90 --- /dev/null +++ b/Libraries/Components/ProgressBarAndroid/__tests__/__snapshots__/ProgressBarAndroid-test.js.snap @@ -0,0 +1,33 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` should render as when mocked 1`] = ` + +`; + +exports[` should render as when not mocked 1`] = ` + +`; + +exports[` should shallow render as when mocked 1`] = ` + +`; + +exports[` should shallow render as when not mocked 1`] = ` + +`; diff --git a/Libraries/Components/ProgressViewIOS/__tests__/ProgressViewIOS-test.js b/Libraries/Components/ProgressViewIOS/__tests__/ProgressViewIOS-test.js new file mode 100644 index 00000000000..48f2105afe4 --- /dev/null +++ b/Libraries/Components/ProgressViewIOS/__tests__/ProgressViewIOS-test.js @@ -0,0 +1,43 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @emails oncall+react_native + * @flow + */ + +'use strict'; + +const React = require('React'); +const ProgressViewIOS = require('../ProgressViewIOS'); + +const render = require('../../../../jest/renderer'); + +describe('', () => { + it('should render as when mocked', () => { + const instance = render.create(); + expect(instance).toMatchSnapshot(); + }); + + it('should shallow render as when mocked', () => { + const output = render.shallow(); + expect(output).toMatchSnapshot(); + }); + + it('should shallow render as when not mocked', () => { + jest.dontMock('ProgressViewIOS'); + + const output = render.shallow(); + expect(output).toMatchSnapshot(); + }); + + it('should render as when not mocked', () => { + jest.dontMock('ProgressViewIOS'); + + const instance = render.create(); + expect(instance).toMatchSnapshot(); + }); +}); diff --git a/Libraries/Components/ProgressViewIOS/__tests__/__snapshots__/ProgressViewIOS-test.js.snap b/Libraries/Components/ProgressViewIOS/__tests__/__snapshots__/ProgressViewIOS-test.js.snap new file mode 100644 index 00000000000..0db8c940aa4 --- /dev/null +++ b/Libraries/Components/ProgressViewIOS/__tests__/__snapshots__/ProgressViewIOS-test.js.snap @@ -0,0 +1,41 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` should render as when mocked 1`] = ` + +`; + +exports[` should render as when not mocked 1`] = ` + +`; + +exports[` should shallow render as when mocked 1`] = ` + +`; + +exports[` should shallow render as when not mocked 1`] = ` + +`; diff --git a/Libraries/Modal/__tests__/Modal-test.js b/Libraries/Modal/__tests__/Modal-test.js new file mode 100644 index 00000000000..9d9b9b89a5b --- /dev/null +++ b/Libraries/Modal/__tests__/Modal-test.js @@ -0,0 +1,60 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @emails oncall+react_native + * @flow + */ + +'use strict'; + +const React = require('React'); +const View = require('View'); +const Modal = require('../Modal'); + +const render = require('../../../jest/renderer'); + +describe('', () => { + it('should render as when mocked', () => { + const instance = render.create( + + + , + ); + expect(instance).toMatchSnapshot(); + }); + + it('should shallow render as when mocked', () => { + const output = render.shallow( + + + , + ); + expect(output).toMatchSnapshot(); + }); + + it('should shallow render as when not mocked', () => { + jest.dontMock('Modal'); + + const output = render.shallow( + + + , + ); + expect(output).toMatchSnapshot(); + }); + + it('should render as when not mocked', () => { + jest.dontMock('Modal'); + + const instance = render.create( + + + , + ); + expect(instance).toMatchSnapshot(); + }); +}); diff --git a/Libraries/Modal/__tests__/__snapshots__/Modal-test.js.snap b/Libraries/Modal/__tests__/__snapshots__/Modal-test.js.snap new file mode 100644 index 00000000000..8aa3579e006 --- /dev/null +++ b/Libraries/Modal/__tests__/__snapshots__/Modal-test.js.snap @@ -0,0 +1,79 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` should render as when mocked 1`] = ` + + + +`; + +exports[` should render as when not mocked 1`] = ` + + + + + + + + + +`; + +exports[` should shallow render as when mocked 1`] = ` + + + +`; + +exports[` should shallow render as when not mocked 1`] = ` + + + +`;