mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Button-test: use act-wrapping abstraction for create
Summary: Migrate `Button-test` to async, `act`-wrapping abstractions in preparation for React 19. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D58653259 fbshipit-source-id: 82e052e5ab328471d74b9f88b05bb887d89c247c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9381c6db25
commit
53c125ee6e
@@ -5,55 +5,55 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {create} from '../../../jest/renderer';
|
||||
import Button from '../Button';
|
||||
import * as React from 'react';
|
||||
import ReactTestRenderer from 'react-test-renderer';
|
||||
|
||||
describe('<Button />', () => {
|
||||
it('should render as expected', () => {
|
||||
expect(ReactTestRenderer.create(<Button title="Test Button" />)).toMatchSnapshot();
|
||||
it('should render as expected', async () => {
|
||||
expect(await create(<Button title="Test Button" />)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should be disabled and it should set accessibilityState to disabled when disabled={true}', () => {
|
||||
it('should be disabled and it should set accessibilityState to disabled when disabled={true}', async() => {
|
||||
expect(
|
||||
ReactTestRenderer.create(<Button title="Test Button" disabled={true} />)
|
||||
await create(<Button title="Test Button" disabled={true} />)
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should be disabled when disabled={true} and accessibilityState={{disabled: true}}', () => {
|
||||
it('should be disabled when disabled={true} and accessibilityState={{disabled: true}}', async() => {
|
||||
expect(
|
||||
ReactTestRenderer.create(<Button title="Test Button" disabled={true} accessibilityState={{disabled: true}} />)
|
||||
await create(<Button title="Test Button" disabled={true} accessibilityState={{disabled: true}} />)
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should be disabled when disabled is empty and accessibilityState={{disabled: true}}', () => {
|
||||
it('should be disabled when disabled is empty and accessibilityState={{disabled: true}}',async () => {
|
||||
expect(
|
||||
ReactTestRenderer.create(<Button title="Test Button" accessibilityState={{disabled: true}} />)
|
||||
await create(<Button title="Test Button" accessibilityState={{disabled: true}} />)
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should overwrite accessibilityState with value of disabled prop', () => {
|
||||
expect(ReactTestRenderer.create(<Button title="Test Button" disabled={true} accessibilityState={{disabled: false}} />)
|
||||
it('should overwrite accessibilityState with value of disabled prop', async() => {
|
||||
expect(await create(<Button title="Test Button" disabled={true} accessibilityState={{disabled: false}} />)
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should not be disabled when disabled={false} and accessibilityState={{disabled: true}}', () => {
|
||||
expect(ReactTestRenderer.create(<Button title="Test Button" disabled={false} accessibilityState={{disabled: true}} />)
|
||||
it('should not be disabled when disabled={false} and accessibilityState={{disabled: true}}', async() => {
|
||||
expect(await create(<Button title="Test Button" disabled={false} accessibilityState={{disabled: true}} />)
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should not be disabled when disabled={false} and accessibilityState={{disabled: false}}', () => {
|
||||
expect(ReactTestRenderer.create( <Button title="Test Button" disabled={false} accessibilityState={{disabled: false}} />)
|
||||
it('should not be disabled when disabled={false} and accessibilityState={{disabled: false}}', async() => {
|
||||
expect(await create( <Button title="Test Button" disabled={false} accessibilityState={{disabled: false}} />)
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no-hide-descendants}', () => {
|
||||
expect(ReactTestRenderer.create( <Button title="Test Button" importantForAccessibility={'no-hide-descendants'} />)
|
||||
it('should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no-hide-descendants}', async() => {
|
||||
expect(await create( <Button title="Test Button" importantForAccessibility={'no-hide-descendants'} />)
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no}', () => {
|
||||
expect(ReactTestRenderer.create( <Button title="Test Button" importantForAccessibility={'no'} />)
|
||||
it('should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no}', async() => {
|
||||
expect( await create( <Button title="Test Button" importantForAccessibility={'no'} />)
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user