-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add displayName to touchables (#29531)
Summary: Since TouchableHighlight and TouchableOpacity are being exported using `forwardRef`, it's messing up jest's snapshots and some matchers. This commit 4b935ae fixed this for components being mocked on [setup.js](https://github.com/facebook/react-native/blob/master/jest/setup.js). However, these Touchables aren't being mocked. It resolves #27721 ## Changelog [General] [Added] - Add displayName to TouchableHighlight and TouchableOpacity Pull Request resolved: #29531 Test Plan: Check the new snapshots. Reviewed By: kacieb Differential Revision: D27485269 Pulled By: yungsters fbshipit-source-id: ba2082a4ae9f97ebe93ba92971d58c9195bdf26d
- Loading branch information
1 parent
679f38f
commit c4e40b8
Showing
11 changed files
with
189 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Libraries/Components/Touchable/__tests__/TouchableNativeFeedback-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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( | ||
<TouchableNativeFeedback style={{}}> | ||
<Text>Touchable</Text> | ||
</TouchableNativeFeedback>, | ||
); | ||
|
||
expect(instance.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('has displayName', () => { | ||
expect(TouchableNativeFeedback.displayName).toEqual( | ||
'TouchableNativeFeedback', | ||
); | ||
}); | ||
}); |
33 changes: 33 additions & 0 deletions
33
Libraries/Components/Touchable/__tests__/TouchableOpacity-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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( | ||
<TouchableOpacity style={{}}> | ||
<Text>Touchable</Text> | ||
</TouchableOpacity>, | ||
); | ||
|
||
expect(instance.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('has displayName', () => { | ||
expect(TouchableOpacity.displayName).toEqual('TouchableOpacity'); | ||
}); | ||
}); |
35 changes: 35 additions & 0 deletions
35
Libraries/Components/Touchable/__tests__/TouchableWithoutFeedback-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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( | ||
<TouchableWithoutFeedback style={{}}> | ||
<Text>Touchable</Text> | ||
</TouchableWithoutFeedback>, | ||
); | ||
|
||
expect(instance.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('has displayName', () => { | ||
expect(TouchableWithoutFeedback.displayName).toEqual( | ||
'TouchableWithoutFeedback', | ||
); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
Libraries/Components/Touchable/__tests__/__snapshots__/TouchableNativeFeedback-test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`TouchableWithoutFeedback renders correctly 1`] = ` | ||
<Text | ||
accessible={true} | ||
focusable={false} | ||
onClick={[Function]} | ||
onResponderGrant={[Function]} | ||
onResponderMove={[Function]} | ||
onResponderRelease={[Function]} | ||
onResponderTerminate={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
> | ||
Touchable | ||
</Text> | ||
`; |
26 changes: 26 additions & 0 deletions
26
Libraries/Components/Touchable/__tests__/__snapshots__/TouchableOpacity-test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`TouchableOpacity renders correctly 1`] = ` | ||
<View | ||
accessible={true} | ||
collapsable={false} | ||
focusable={false} | ||
nativeID="animatedComponent" | ||
onClick={[Function]} | ||
onResponderGrant={[Function]} | ||
onResponderMove={[Function]} | ||
onResponderRelease={[Function]} | ||
onResponderTerminate={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
style={ | ||
Object { | ||
"opacity": 1, | ||
} | ||
} | ||
> | ||
<Text> | ||
Touchable | ||
</Text> | ||
</View> | ||
`; |
17 changes: 17 additions & 0 deletions
17
Libraries/Components/Touchable/__tests__/__snapshots__/TouchableWithoutFeedback-test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`TouchableWithoutFeedback renders correctly 1`] = ` | ||
<Text | ||
accessible={true} | ||
focusable={false} | ||
onClick={[Function]} | ||
onResponderGrant={[Function]} | ||
onResponderMove={[Function]} | ||
onResponderRelease={[Function]} | ||
onResponderTerminate={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
> | ||
Touchable | ||
</Text> | ||
`; |