-
-
Notifications
You must be signed in to change notification settings - Fork 252
/
Copy pathpopupRender.test.tsx
57 lines (52 loc) · 1.49 KB
/
popupRender.test.tsx
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
import React from 'react';
import { render } from '@testing-library/react';
import Menu, { SubMenu, Item as MenuItem } from '../src';
import type { ReactElement } from 'react';
describe('Menu PopupRender Tests', () => {
const basicPopupRender = (node: ReactElement) => (
<div className="custom-popup" data-testid="custom-popup">
{React.cloneElement(node, {
className: `${node.props.className || ''} custom-popup-content`,
})}
</div>
);
it('should render popup with custom wrapper', async () => {
const { container } = render(
<Menu
mode="horizontal"
popupRender={basicPopupRender}
openKeys={['test']}
>
<SubMenu key="test" title="Test">
<MenuItem key="child">Child</MenuItem>
</SubMenu>
</Menu>,
);
expect(
container.querySelectorAll('.rc-menu-submenu-horizontal')[0],
).toHaveClass('rc-menu-submenu-open');
});
it('should work with items prop', async () => {
const items = [
{
key: 'submenu1',
label: 'SubMenu 1',
children: [
{ key: 'child1', label: 'Child 1' },
{ key: 'child2', label: 'Child 2' },
],
},
];
const { container } = render(
<Menu
mode="horizontal"
popupRender={basicPopupRender}
items={items}
openKeys={['submenu1']}
/>,
);
expect(
container.querySelectorAll('.rc-menu-submenu-horizontal')[0],
).toHaveClass('rc-menu-submenu-open');
});
});