diff --git a/Libraries/Components/Touchable/TouchableHighlight.js b/Libraries/Components/Touchable/TouchableHighlight.js index 52ed550b3896f6..c0faac9bdda0e6 100644 --- a/Libraries/Components/Touchable/TouchableHighlight.js +++ b/Libraries/Components/Touchable/TouchableHighlight.js @@ -357,9 +357,13 @@ class TouchableHighlight extends React.Component { } } -module.exports = (React.forwardRef((props, hostRef) => ( +const Touchable = (React.forwardRef((props, hostRef) => ( )): React.AbstractComponent< $ReadOnly<$Diff|}>>, React.ElementRef, >); + +Touchable.displayName = 'TouchableHighlight'; + +module.exports = Touchable; diff --git a/Libraries/Components/Touchable/TouchableNativeFeedback.js b/Libraries/Components/Touchable/TouchableNativeFeedback.js index 739ea4c15a74f2..e18b625ab868c2 100644 --- a/Libraries/Components/Touchable/TouchableNativeFeedback.js +++ b/Libraries/Components/Touchable/TouchableNativeFeedback.js @@ -313,4 +313,6 @@ const getBackgroundProp = : {nativeBackgroundAndroid: background} : (background, useForeground) => null; +TouchableNativeFeedback.displayName = 'TouchableNativeFeedback'; + module.exports = TouchableNativeFeedback; diff --git a/Libraries/Components/Touchable/TouchableOpacity.js b/Libraries/Components/Touchable/TouchableOpacity.js index 7a17eef9a2fdbe..6ae8cd850f7824 100644 --- a/Libraries/Components/Touchable/TouchableOpacity.js +++ b/Libraries/Components/Touchable/TouchableOpacity.js @@ -265,6 +265,10 @@ class TouchableOpacity extends React.Component { } } -module.exports = (React.forwardRef((props, ref) => ( +const Touchable = (React.forwardRef((props, ref) => ( )): React.AbstractComponent>); + +Touchable.displayName = 'TouchableOpacity'; + +module.exports = Touchable; diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index 0a9ec5518310f9..2f06d41031f20f 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -157,4 +157,6 @@ function createPressabilityConfig(props: Props): PressabilityConfig { }; } +TouchableWithoutFeedback.displayName = 'TouchableWithoutFeedback'; + module.exports = TouchableWithoutFeedback; diff --git a/Libraries/Components/Touchable/__tests__/TouchableHighlight-test.js b/Libraries/Components/Touchable/__tests__/TouchableHighlight-test.js index 2f2b0ff3106f3b..f25f4150dedf31 100644 --- a/Libraries/Components/Touchable/__tests__/TouchableHighlight-test.js +++ b/Libraries/Components/Touchable/__tests__/TouchableHighlight-test.js @@ -11,14 +11,15 @@ 'use strict'; import * as React from 'react'; -import ReactTestRenderer from 'react-test-renderer'; import Text from '../../../Text/Text'; import View from '../../View/View'; import TouchableHighlight from '../TouchableHighlight'; +const render = require('../../../../jest/renderer'); + describe('TouchableHighlight', () => { it('renders correctly', () => { - const instance = ReactTestRenderer.create( + const instance = render.create( Touchable , @@ -26,12 +27,16 @@ describe('TouchableHighlight', () => { expect(instance.toJSON()).toMatchSnapshot(); }); + + it('has displayName', () => { + expect(TouchableHighlight.displayName).toEqual('TouchableHighlight'); + }); }); describe('TouchableHighlight with disabled state', () => { it('should be disabled when disabled is true', () => { expect( - ReactTestRenderer.create( + render.create( , @@ -41,7 +46,7 @@ describe('TouchableHighlight with disabled state', () => { it('should be disabled when disabled is true and accessibilityState is empty', () => { expect( - ReactTestRenderer.create( + render.create( , @@ -51,7 +56,7 @@ describe('TouchableHighlight with disabled state', () => { it('should keep accessibilityState when disabled is true', () => { expect( - ReactTestRenderer.create( + render.create( @@ -63,7 +68,7 @@ describe('TouchableHighlight with disabled state', () => { it('should overwrite accessibilityState with value of disabled prop', () => { expect( - ReactTestRenderer.create( + render.create( @@ -75,7 +80,7 @@ describe('TouchableHighlight with disabled state', () => { it('should disable button when accessibilityState is disabled', () => { expect( - ReactTestRenderer.create( + render.create( , diff --git a/Libraries/Components/Touchable/__tests__/TouchableNativeFeedback-test.js b/Libraries/Components/Touchable/__tests__/TouchableNativeFeedback-test.js new file mode 100644 index 00000000000000..766912665d6d6b --- /dev/null +++ b/Libraries/Components/Touchable/__tests__/TouchableNativeFeedback-test.js @@ -0,0 +1,35 @@ +/** + * 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 + */ + +'use strict'; + +const React = require('react'); +const Text = require('../../../Text/Text'); +const TouchableNativeFeedback = require('../TouchableNativeFeedback'); + +const render = require('../../../../jest/renderer'); + +describe('TouchableWithoutFeedback', () => { + it('renders correctly', () => { + const instance = render.create( + + Touchable + , + ); + + expect(instance.toJSON()).toMatchSnapshot(); + }); + + it('has displayName', () => { + expect(TouchableNativeFeedback.displayName).toEqual( + 'TouchableNativeFeedback', + ); + }); +}); diff --git a/Libraries/Components/Touchable/__tests__/TouchableOpacity-test.js b/Libraries/Components/Touchable/__tests__/TouchableOpacity-test.js new file mode 100644 index 00000000000000..77a0575b7e49f0 --- /dev/null +++ b/Libraries/Components/Touchable/__tests__/TouchableOpacity-test.js @@ -0,0 +1,33 @@ +/** + * 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 + */ + +'use strict'; + +const React = require('react'); +const Text = require('../../../Text/Text'); +const TouchableOpacity = require('../TouchableOpacity'); + +const render = require('../../../../jest/renderer'); + +describe('TouchableOpacity', () => { + it('renders correctly', () => { + const instance = render.create( + + Touchable + , + ); + + expect(instance.toJSON()).toMatchSnapshot(); + }); + + it('has displayName', () => { + expect(TouchableOpacity.displayName).toEqual('TouchableOpacity'); + }); +}); diff --git a/Libraries/Components/Touchable/__tests__/TouchableWithoutFeedback-test.js b/Libraries/Components/Touchable/__tests__/TouchableWithoutFeedback-test.js new file mode 100644 index 00000000000000..1812253fef73e9 --- /dev/null +++ b/Libraries/Components/Touchable/__tests__/TouchableWithoutFeedback-test.js @@ -0,0 +1,35 @@ +/** + * 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 + */ + +'use strict'; + +const React = require('react'); +const Text = require('../../../Text/Text'); +const TouchableWithoutFeedback = require('../TouchableWithoutFeedback'); + +const render = require('../../../../jest/renderer'); + +describe('TouchableWithoutFeedback', () => { + it('renders correctly', () => { + const instance = render.create( + + Touchable + , + ); + + expect(instance.toJSON()).toMatchSnapshot(); + }); + + it('has displayName', () => { + expect(TouchableWithoutFeedback.displayName).toEqual( + 'TouchableWithoutFeedback', + ); + }); +}); diff --git a/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableNativeFeedback-test.js.snap b/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableNativeFeedback-test.js.snap new file mode 100644 index 00000000000000..27c69f493086da --- /dev/null +++ b/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableNativeFeedback-test.js.snap @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`TouchableWithoutFeedback renders correctly 1`] = ` + + Touchable + +`; diff --git a/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableOpacity-test.js.snap b/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableOpacity-test.js.snap new file mode 100644 index 00000000000000..c1a2ee35013e24 --- /dev/null +++ b/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableOpacity-test.js.snap @@ -0,0 +1,26 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`TouchableOpacity renders correctly 1`] = ` + + + Touchable + + +`; diff --git a/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableWithoutFeedback-test.js.snap b/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableWithoutFeedback-test.js.snap new file mode 100644 index 00000000000000..27c69f493086da --- /dev/null +++ b/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableWithoutFeedback-test.js.snap @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`TouchableWithoutFeedback renders correctly 1`] = ` + + Touchable + +`;