Skip to content

Commit

Permalink
feat: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
coderz-w committed Jun 10, 2024
1 parent 6cc8318 commit b7ae918
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions tests/SubMenu.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,30 @@ describe('SubMenu', () => {
).textContent;
expect(childText).toEqual('submenu');
});
it("The submenu item with key '' must not persistently remain active.", () => {
const { container } = render(
<Menu
mode="horizontal"
items={[
{
label: '菜单一',
key: '1',
},
{
label: '菜单二',
key: '',
children: [
{
label: 'Navigation One1',
key: 'mail1',
},
],
},
]}
/>,
);
expect(container.querySelector('.rc-menu-submenu-active')).toBeFalsy()
});

describe('openSubMenuOnMouseEnter and closeSubMenuOnMouseLeave are true', () => {
it('toggles when mouse enter and leave', () => {
Expand Down Expand Up @@ -496,8 +520,14 @@ describe('SubMenu', () => {

fireEvent.mouseEnter(container.querySelector('.rc-menu-submenu-title'));
runAllTimer();
expect((container.querySelector('.rc-menu-submenu-popup') as HTMLElement).style.zIndex).toEqual('100');
expect((container.querySelector('.rc-menu-submenu-popup') as HTMLElement).style.width).toEqual('150px');
expect(
(container.querySelector('.rc-menu-submenu-popup') as HTMLElement).style
.zIndex,
).toEqual('100');
expect(
(container.querySelector('.rc-menu-submenu-popup') as HTMLElement).style
.width,
).toEqual('150px');
});
});
/* eslint-enable */

0 comments on commit b7ae918

Please sign in to comment.