-
-
Notifications
You must be signed in to change notification settings - Fork 262
Expand file tree
/
Copy pathOptions.spec.tsx
More file actions
75 lines (69 loc) · 1.67 KB
/
Options.spec.tsx
File metadata and controls
75 lines (69 loc) · 1.67 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
73
74
75
/* eslint-disable no-undef */
import { fireEvent, render } from '@testing-library/react';
import React from 'react';
import Menu from '../src';
describe('Options', () => {
it('should work', () => {
const { container } = render(
<Menu
mode="inline"
openKeys={['sub1']}
items={[
// Invalid
null,
{
label: 'SubMenu',
key: 'sub1',
children: [
{
type: 'group',
label: 'Menu Group',
children: [
{
label: 'Menu Item 1',
key: '1',
},
{
label: 'Menu Item 2',
key: '2',
},
],
},
],
},
{
type: 'divider',
},
]}
/>,
);
expect(container.children).toMatchSnapshot();
});
it('key type is matched', () => {
const onSelect = jest.fn();
const { container } = render(
<Menu
items={[
{
label: 'Menu Item 1',
key: "1",
},
{
label: 'Menu Item 2',
key: 2,
},
]}
onSelect={onSelect}
/>,
);
fireEvent.click(container.querySelectorAll('.rc-menu-item')[0]);
expect(onSelect).toHaveBeenCalledWith(
expect.objectContaining({ selectedKeys: ['1'] }),
);
fireEvent.click(container.querySelectorAll('.rc-menu-item')[1]);
expect(onSelect).toHaveBeenCalledWith(
expect.objectContaining({ selectedKeys: [2] }),
);
});
});
/* eslint-enable */