mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: https://github.com/facebook/react-native/issues/30950 automatically set `disabled` to accessibilityState when TouchableHighlight is disabled ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [General] [Changed] - Set disabled accessibilityState when TouchableHighlight is disabled Pull Request resolved: https://github.com/facebook/react-native/pull/31135 Test Plan: Tested on physical android device that pressing disabled TouchableHighlight announces "dim" when talkback is on Reviewed By: yungsters, nadiia Differential Revision: D27157207 Pulled By: kacieb fbshipit-source-id: b8e24aad699c43cf02401b3ba39726a06b751995
86 lines
2.2 KiB
JavaScript
86 lines
2.2 KiB
JavaScript
/**
|
|
* 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 Text from '../../../Text/Text';
|
|
import View from '../../View/View';
|
|
import TouchableHighlight from '../TouchableHighlight';
|
|
|
|
describe('TouchableHighlight', () => {
|
|
it('renders correctly', () => {
|
|
const instance = ReactTestRenderer.create(
|
|
<TouchableHighlight style={{}}>
|
|
<Text>Touchable</Text>
|
|
</TouchableHighlight>,
|
|
);
|
|
|
|
expect(instance.toJSON()).toMatchSnapshot();
|
|
});
|
|
});
|
|
|
|
describe('TouchableHighlight with disabled state', () => {
|
|
it('should be disabled when disabled is true', () => {
|
|
expect(
|
|
ReactTestRenderer.create(
|
|
<TouchableHighlight disabled={true}>
|
|
<View />
|
|
</TouchableHighlight>,
|
|
),
|
|
).toMatchSnapshot();
|
|
});
|
|
|
|
it('should be disabled when disabled is true and accessibilityState is empty', () => {
|
|
expect(
|
|
ReactTestRenderer.create(
|
|
<TouchableHighlight disabled={true} accessibilityState={{}}>
|
|
<View />
|
|
</TouchableHighlight>,
|
|
),
|
|
).toMatchSnapshot();
|
|
});
|
|
|
|
it('should keep accessibilityState when disabled is true', () => {
|
|
expect(
|
|
ReactTestRenderer.create(
|
|
<TouchableHighlight
|
|
disabled={true}
|
|
accessibilityState={{checked: true}}>
|
|
<View />
|
|
</TouchableHighlight>,
|
|
),
|
|
).toMatchSnapshot();
|
|
});
|
|
|
|
it('should overwrite accessibilityState with value of disabled prop', () => {
|
|
expect(
|
|
ReactTestRenderer.create(
|
|
<TouchableHighlight
|
|
disabled={true}
|
|
accessibilityState={{disabled: false}}>
|
|
<View />
|
|
</TouchableHighlight>,
|
|
),
|
|
).toMatchSnapshot();
|
|
});
|
|
|
|
it('should disable button when accessibilityState is disabled', () => {
|
|
expect(
|
|
ReactTestRenderer.create(
|
|
<TouchableHighlight accessibilityState={{disabled: true}}>
|
|
<View />
|
|
</TouchableHighlight>,
|
|
),
|
|
).toMatchSnapshot();
|
|
});
|
|
});
|