|
1 | 1 | import * as React from 'react';
|
2 |
| -import { View } from 'react-native'; |
| 2 | +import { View, Text } from 'react-native'; |
3 | 3 | import { render } from '../..';
|
4 | 4 |
|
5 | 5 | describe('accessibility value', () => {
|
@@ -58,4 +58,44 @@ describe('accessibility value', () => {
|
58 | 58 | expect(queryByRole('adjustable', { value: { text: 'No' } })).toBeFalsy();
|
59 | 59 | expect(queryByRole('adjustable', { value: { text: /no/ } })).toBeFalsy();
|
60 | 60 | });
|
| 61 | + |
| 62 | + test('matches using single value and other options', () => { |
| 63 | + const { getByRole } = render( |
| 64 | + <Text |
| 65 | + accessibilityRole="adjustable" |
| 66 | + accessibilityState={{ disabled: true }} |
| 67 | + accessibilityValue={{ min: 10, max: 20, now: 12, text: 'Hello' }} |
| 68 | + > |
| 69 | + Hello |
| 70 | + </Text> |
| 71 | + ); |
| 72 | + |
| 73 | + expect( |
| 74 | + getByRole('adjustable', { name: 'Hello', value: { min: 10 } }) |
| 75 | + ).toBeTruthy(); |
| 76 | + expect( |
| 77 | + getByRole('adjustable', { disabled: true, value: { min: 10 } }) |
| 78 | + ).toBeTruthy(); |
| 79 | + |
| 80 | + expect(() => |
| 81 | + getByRole('adjustable', { name: 'Hello', value: { min: 5 } }) |
| 82 | + ).toThrowErrorMatchingInlineSnapshot( |
| 83 | + `"Unable to find an element with role: "adjustable", name: "Hello", min value: 5"` |
| 84 | + ); |
| 85 | + expect(() => |
| 86 | + getByRole('adjustable', { name: 'World', value: { min: 10 } }) |
| 87 | + ).toThrowErrorMatchingInlineSnapshot( |
| 88 | + `"Unable to find an element with role: "adjustable", name: "World", min value: 10"` |
| 89 | + ); |
| 90 | + expect(() => |
| 91 | + getByRole('adjustable', { name: 'Hello', value: { min: 5 } }) |
| 92 | + ).toThrowErrorMatchingInlineSnapshot( |
| 93 | + `"Unable to find an element with role: "adjustable", name: "Hello", min value: 5"` |
| 94 | + ); |
| 95 | + expect(() => |
| 96 | + getByRole('adjustable', { selected: true, value: { min: 10 } }) |
| 97 | + ).toThrowErrorMatchingInlineSnapshot( |
| 98 | + `"Unable to find an element with role: "adjustable", selected state: true, min value: 10"` |
| 99 | + ); |
| 100 | + }); |
61 | 101 | });
|
0 commit comments