-
-
Notifications
You must be signed in to change notification settings - Fork 489
Expand file tree
/
Copy pathAccessibility.test.tsx
More file actions
72 lines (62 loc) · 1.98 KB
/
Accessibility.test.tsx
File metadata and controls
72 lines (62 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { mount } from 'enzyme';
import * as React from 'react';
import KeyCode from 'rc-util/lib/KeyCode';
import Select from '../src';
import { injectRunAllTimers, expectOpen } from './utils/common';
describe('Select.Accessibility', () => {
injectRunAllTimers(jest);
beforeEach(() => {
jest.useFakeTimers();
});
afterEach(() => {
jest.useRealTimers();
});
it('pass aria info to internal input', () => {
const MySelect = Select as any;
const wrapper = mount(<MySelect aria-label="light" data-attr="bamboo" useless="2333" />);
expect(wrapper.find('.rc-select-selection-search-input').props()).toEqual(
expect.objectContaining({
'aria-label': 'light',
}),
);
});
// https://github.com/ant-design/ant-design/issues/31850
it('active index should keep', () => {
const wrapper = mount(
<Select
showSearch
options={[
{
label: 'Little',
value: 'little',
},
{
label: 'Bamboo',
value: 'bamboo',
},
{
label: 'Light',
value: 'light',
},
]}
/>,
);
// First Match
wrapper.find('.rc-select-selection-search-input').simulate('change', { target: { value: 'b' } });
jest.runAllTimers();
expectOpen(wrapper);
expect(
wrapper.find('.rc-select-item-option-active .rc-select-item-option-content').text(),
).toEqual('Bamboo');
wrapper.find('.rc-select-selection-search-input').simulate('keyDown', { which: KeyCode.ENTER });
expectOpen(wrapper, false);
// Next Match
wrapper.find('.rc-select-selection-search-input').simulate('change', { target: { value: '' } });
wrapper.find('.rc-select-selection-search-input').simulate('change', { target: { value: 'g' } });
jest.runAllTimers();
expectOpen(wrapper);
expect(
wrapper.find('.rc-select-item-option-active .rc-select-item-option-content').text(),
).toEqual('Light');
});
});