forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TouchableNativeFeedback: sync disabled prop with accessibilityState (f…
- Loading branch information
1 parent
4cc3aa8
commit cd04626
Showing
3 changed files
with
218 additions
and
2 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
94 changes: 94 additions & 0 deletions
94
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,94 @@ | ||
/** | ||
* 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'; | ||
|
||
import * as React from 'react'; | ||
import ReactTestRenderer from 'react-test-renderer'; | ||
import TouchableNativeFeedback from '../TouchableNativeFeedback'; | ||
import View from '../../View/View'; | ||
|
||
describe('<TouchableNativeFeedback />', () => { | ||
it('should render as expected', () => { | ||
const instance = ReactTestRenderer.create( | ||
<TouchableNativeFeedback> | ||
<View /> | ||
</TouchableNativeFeedback>, | ||
); | ||
|
||
expect(instance.toJSON()).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('<TouchableNativeFeedback disabled={true}>', () => { | ||
it('should be disabled when disabled is true', () => { | ||
expect( | ||
ReactTestRenderer.create( | ||
<TouchableNativeFeedback disabled={true}> | ||
<View /> | ||
</TouchableNativeFeedback>, | ||
), | ||
).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('<TouchableNativeFeedback disabled={true} accessibilityState={{}}>', () => { | ||
it('should be disabled when disabled is true and accessibilityState is empty', () => { | ||
expect( | ||
ReactTestRenderer.create( | ||
<TouchableNativeFeedback disabled={true} accessibilityState={{}}> | ||
<View /> | ||
</TouchableNativeFeedback>, | ||
), | ||
).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('<TouchableNativeFeedback disabled={true} accessibilityState={{checked: true}}>', () => { | ||
it('should keep accessibilityState when disabled is true', () => { | ||
expect( | ||
ReactTestRenderer.create( | ||
<TouchableNativeFeedback | ||
disabled={true} | ||
accessibilityState={{checked: true}}> | ||
<View /> | ||
</TouchableNativeFeedback>, | ||
), | ||
).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('<TouchableNativeFeedback disabled={true} accessibilityState={{disabled:false}}>', () => { | ||
it('should overwrite accessibilityState with value of disabled prop', () => { | ||
expect( | ||
ReactTestRenderer.create( | ||
<TouchableNativeFeedback | ||
disabled={true} | ||
accessibilityState={{disabled: false}}> | ||
<View /> | ||
</TouchableNativeFeedback>, | ||
), | ||
).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('<TouchableNativeFeedback disabled={false} accessibilityState={{disabled:true}}>', () => { | ||
it('should overwrite accessibilityState with value of disabled prop', () => { | ||
expect( | ||
ReactTestRenderer.create( | ||
<TouchableNativeFeedback | ||
disabled={false} | ||
accessibilityState={{disabled: true}}> | ||
<View /> | ||
</TouchableNativeFeedback>, | ||
), | ||
).toMatchSnapshot(); | ||
}); | ||
}); |
111 changes: 111 additions & 0 deletions
111
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,111 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<TouchableNativeFeedback /> should render as expected 1`] = ` | ||
<View | ||
accessible={true} | ||
focusable={false} | ||
onClick={[Function]} | ||
onResponderGrant={[Function]} | ||
onResponderMove={[Function]} | ||
onResponderRelease={[Function]} | ||
onResponderTerminate={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
/> | ||
`; | ||
|
||
exports[`<TouchableNativeFeedback disabled={true}> should be disabled when disabled is true 1`] = ` | ||
<View | ||
accessibilityState={ | ||
Object { | ||
"disabled": true, | ||
} | ||
} | ||
accessible={true} | ||
focusable={false} | ||
onClick={[Function]} | ||
onResponderGrant={[Function]} | ||
onResponderMove={[Function]} | ||
onResponderRelease={[Function]} | ||
onResponderTerminate={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
/> | ||
`; | ||
exports[`<TouchableNativeFeedback disabled={true} accessibilityState={{}}> should be disabled when disabled is true and accessibilityState is empty 1`] = ` | ||
<View | ||
accessibilityState={ | ||
Object { | ||
"disabled": true, | ||
} | ||
} | ||
accessible={true} | ||
focusable={false} | ||
onClick={[Function]} | ||
onResponderGrant={[Function]} | ||
onResponderMove={[Function]} | ||
onResponderRelease={[Function]} | ||
onResponderTerminate={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
/> | ||
`; | ||
exports[`<TouchableNativeFeedback disabled={true} accessibilityState={{checked: true}}> should keep accessibilityState when disabled is true 1`] = ` | ||
<View | ||
accessibilityState={ | ||
Object { | ||
"checked": true, | ||
"disabled": true, | ||
} | ||
} | ||
accessible={true} | ||
focusable={false} | ||
onClick={[Function]} | ||
onResponderGrant={[Function]} | ||
onResponderMove={[Function]} | ||
onResponderRelease={[Function]} | ||
onResponderTerminate={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
/> | ||
`; | ||
exports[`<TouchableNativeFeedback disabled={true} accessibilityState={{disabled:false}}> should overwrite accessibilityState with value of disabled prop 1`] = ` | ||
<View | ||
accessibilityState={ | ||
Object { | ||
"disabled": true, | ||
} | ||
} | ||
accessible={true} | ||
focusable={false} | ||
onClick={[Function]} | ||
onResponderGrant={[Function]} | ||
onResponderMove={[Function]} | ||
onResponderRelease={[Function]} | ||
onResponderTerminate={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
/> | ||
`; | ||
exports[`<TouchableNativeFeedback disabled={false} accessibilityState={{disabled:true}}> should overwrite accessibilityState with value of disabled prop 1`] = ` | ||
<View | ||
accessibilityState={ | ||
Object { | ||
"disabled": false, | ||
} | ||
} | ||
accessible={true} | ||
focusable={false} | ||
onClick={[Function]} | ||
onResponderGrant={[Function]} | ||
onResponderMove={[Function]} | ||
onResponderRelease={[Function]} | ||
onResponderTerminate={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
/> | ||
`; |