diff --git a/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-test.js b/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-test.js index ec97e8255..db9baca9d 100644 --- a/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-test.js +++ b/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-test.js @@ -15,7 +15,7 @@ const React = require('React'); const ActivityIndicator = require('ActivityIndicator'); const render = require('../../../../jest/renderer'); -describe('ActivityIndicator', () => { +describe('', () => { it('should set displayName to prevent regressions', () => { expect(ActivityIndicator.displayName).toBe('ActivityIndicator'); }); diff --git a/Libraries/Components/ActivityIndicator/__tests__/__snapshots__/ActivityIndicator-test.js.snap b/Libraries/Components/ActivityIndicator/__tests__/__snapshots__/ActivityIndicator-test.js.snap index d8cbec0f2..51f69150a 100644 --- a/Libraries/Components/ActivityIndicator/__tests__/__snapshots__/ActivityIndicator-test.js.snap +++ b/Libraries/Components/ActivityIndicator/__tests__/__snapshots__/ActivityIndicator-test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`ActivityIndicator should render as when mocked 1`] = ` +exports[` should render as when mocked 1`] = ` when mocked 1`] /> `; -exports[`ActivityIndicator should render as when not mocked 1`] = ` +exports[` should render as when not mocked 1`] = ` when not mocked 1`] = ` `; -exports[`ActivityIndicator should shallow render as when mocked 1`] = ` +exports[` should shallow render as when mocked 1`] = ` when moc /> `; -exports[`ActivityIndicator should shallow render as when not mocked 1`] = ` +exports[` should shallow render as when not mocked 1`] = ` { + 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('DatePickerIOS'); + + const output = render.shallow( + , + ); + expect(output).toMatchSnapshot(); + }); + + it('should render as when not mocked', () => { + jest.dontMock('DatePickerIOS'); + + const instance = render.create( + , + ); + expect(instance).toMatchSnapshot(); + }); +}); diff --git a/Libraries/Components/DatePicker/__tests__/__snapshots__/DatePickerIOS-test.js.snap b/Libraries/Components/DatePicker/__tests__/__snapshots__/DatePickerIOS-test.js.snap new file mode 100644 index 000000000..cca126b20 --- /dev/null +++ b/Libraries/Components/DatePicker/__tests__/__snapshots__/DatePickerIOS-test.js.snap @@ -0,0 +1,51 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DatePickerIOS should render as when mocked 1`] = ` + + + +`; + +exports[`DatePickerIOS should render as when not mocked 1`] = ` + + + +`; + +exports[`DatePickerIOS should shallow render as when mocked 1`] = ` + +`; + +exports[`DatePickerIOS should shallow render as when not mocked 1`] = ` + +`; diff --git a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js index 3f7866b5e..7819ea1db 100644 --- a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +++ b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js @@ -21,7 +21,6 @@ const nullthrows = require('nullthrows'); const DrawerConsts = UIManager.getViewManagerConfig('AndroidDrawerLayout') .Constants; - const dismissKeyboard = require('dismissKeyboard'); const AndroidDrawerLayoutNativeComponent = require('AndroidDrawerLayoutNativeComponent'); diff --git a/Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js b/Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js new file mode 100644 index 000000000..0d8712880 --- /dev/null +++ b/Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js @@ -0,0 +1,69 @@ +/** + * 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 DrawerLayoutAndroid = require('../DrawerLayoutAndroid.android'); +const View = require('View'); + +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('DrawerLayoutAndroid'); + + const output = render.shallow( + } + />, + ); + expect(output).toMatchSnapshot(); + }); + + it('should render as when not mocked', () => { + jest.dontMock('DrawerLayoutAndroid'); + + const instance = render.create( + } + />, + ); + expect(instance).toMatchSnapshot(); + }); +}); diff --git a/Libraries/Components/DrawerAndroid/__tests__/__snapshots__/DrawerAndroid-test.js.snap b/Libraries/Components/DrawerAndroid/__tests__/__snapshots__/DrawerAndroid-test.js.snap new file mode 100644 index 000000000..7c52a4807 --- /dev/null +++ b/Libraries/Components/DrawerAndroid/__tests__/__snapshots__/DrawerAndroid-test.js.snap @@ -0,0 +1,125 @@ +// 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/TextInput/__tests__/InputAccessoryView-test.js b/Libraries/Components/TextInput/__tests__/InputAccessoryView-test.js new file mode 100644 index 000000000..ed2081dac --- /dev/null +++ b/Libraries/Components/TextInput/__tests__/InputAccessoryView-test.js @@ -0,0 +1,59 @@ +/** + * 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 InputAccessoryView = require('InputAccessoryView'); +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('InputAccessoryView'); + + const output = render.shallow( + + + , + ); + expect(output).toMatchSnapshot(); + }); + + it('should render as when not mocked', () => { + jest.dontMock('InputAccessoryView'); + + const instance = render.create( + + + , + ); + expect(instance).toMatchSnapshot(); + }); +}); diff --git a/Libraries/Components/TextInput/__tests__/__snapshots__/InputAccessoryView-test.js.snap b/Libraries/Components/TextInput/__tests__/__snapshots__/InputAccessoryView-test.js.snap new file mode 100644 index 000000000..d9e53dc1a --- /dev/null +++ b/Libraries/Components/TextInput/__tests__/__snapshots__/InputAccessoryView-test.js.snap @@ -0,0 +1,49 @@ +// 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/Image/__tests__/Image-test.js b/Libraries/Image/__tests__/Image-test.js new file mode 100644 index 000000000..bc42e9c55 --- /dev/null +++ b/Libraries/Image/__tests__/Image-test.js @@ -0,0 +1,42 @@ +/** + * 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 Image = require('Image'); +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('Image'); + + const output = render.shallow(); + expect(output).toMatchSnapshot(); + }); + + it('should render as when not mocked', () => { + jest.dontMock('Image'); + + const instance = render.create(); + expect(instance).toMatchSnapshot(); + }); +}); diff --git a/Libraries/Image/__tests__/__snapshots__/Image-test.js.snap b/Libraries/Image/__tests__/__snapshots__/Image-test.js.snap new file mode 100644 index 000000000..2d857eafd --- /dev/null +++ b/Libraries/Image/__tests__/__snapshots__/Image-test.js.snap @@ -0,0 +1,51 @@ +// 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 not mocked 1`] = ` + +`; + +exports[` should shallow render as when mocked 1`] = ` + +`; diff --git a/jest/setup.js b/jest/setup.js index e40da3659..f3524812f 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -254,7 +254,17 @@ const mockNativeModules = { createView: jest.fn(), dispatchViewManagerCommand: jest.fn(), focus: jest.fn(), - getViewManagerConfig: jest.fn(), + getViewManagerConfig: jest.fn(name => { + if (name === 'AndroidDrawerLayout') { + return { + Constants: { + DrawerPosition: { + Left: 10, + }, + }, + }; + } + }), setChildren: jest.fn(), manageChildren: jest.fn(), updateView: jest.fn(),