|
|
@ -8,12 +8,13 @@ import {
|
|
|
|
import React, { useMemo, useState } from 'react';
|
|
|
|
import React, { useMemo, useState } from 'react';
|
|
|
|
import type { MenuProps, MenuRef } from '..';
|
|
|
|
import type { MenuProps, MenuRef } from '..';
|
|
|
|
import Menu from '..';
|
|
|
|
import Menu from '..';
|
|
|
|
|
|
|
|
import { TriggerMockContext } from '../../../tests/shared/demoTestContext';
|
|
|
|
import mountTest from '../../../tests/shared/mountTest';
|
|
|
|
import mountTest from '../../../tests/shared/mountTest';
|
|
|
|
import rtlTest from '../../../tests/shared/rtlTest';
|
|
|
|
import rtlTest from '../../../tests/shared/rtlTest';
|
|
|
|
import { act, fireEvent, render } from '../../../tests/utils';
|
|
|
|
import { act, fireEvent, render } from '../../../tests/utils';
|
|
|
|
import Layout from '../../layout';
|
|
|
|
|
|
|
|
import initCollapseMotion from '../../_util/motion';
|
|
|
|
import initCollapseMotion from '../../_util/motion';
|
|
|
|
import { noop } from '../../_util/warning';
|
|
|
|
import { noop } from '../../_util/warning';
|
|
|
|
|
|
|
|
import Layout from '../../layout';
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(globalThis, 'IS_REACT_ACT_ENVIRONMENT', {
|
|
|
|
Object.defineProperty(globalThis, 'IS_REACT_ACT_ENVIRONMENT', {
|
|
|
|
writable: true,
|
|
|
|
writable: true,
|
|
|
@ -824,7 +825,7 @@ describe('Menu', () => {
|
|
|
|
const onOpen = jest.fn();
|
|
|
|
const onOpen = jest.fn();
|
|
|
|
const onClose = jest.fn();
|
|
|
|
const onClose = jest.fn();
|
|
|
|
const Demo: React.FC = () => {
|
|
|
|
const Demo: React.FC = () => {
|
|
|
|
const menuProps = useMemo<MenuProps>(() => ({ onOpen, onClose }) as MenuProps, []);
|
|
|
|
const menuProps = useMemo<MenuProps>(() => ({ onOpen, onClose } as MenuProps), []);
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Menu
|
|
|
|
<Menu
|
|
|
|
{...menuProps}
|
|
|
|
{...menuProps}
|
|
|
@ -859,7 +860,7 @@ describe('Menu', () => {
|
|
|
|
it('should keep selectedKeys in state when collapsed to 0px', () => {
|
|
|
|
it('should keep selectedKeys in state when collapsed to 0px', () => {
|
|
|
|
jest.useFakeTimers();
|
|
|
|
jest.useFakeTimers();
|
|
|
|
const Demo: React.FC<MenuProps> = (props) => {
|
|
|
|
const Demo: React.FC<MenuProps> = (props) => {
|
|
|
|
const menuProps = useMemo<MenuProps>(() => ({ collapsedWidth: 0 }) as MenuProps, []);
|
|
|
|
const menuProps = useMemo<MenuProps>(() => ({ collapsedWidth: 0 } as MenuProps), []);
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Menu
|
|
|
|
<Menu
|
|
|
|
mode="inline"
|
|
|
|
mode="inline"
|
|
|
@ -1099,4 +1100,27 @@ describe('Menu', () => {
|
|
|
|
'0',
|
|
|
|
'0',
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('Overflow indicator className should not override menu class', () => {
|
|
|
|
|
|
|
|
const { container } = render(
|
|
|
|
|
|
|
|
<TriggerMockContext.Provider value={{ popupVisible: true }}>
|
|
|
|
|
|
|
|
<Menu
|
|
|
|
|
|
|
|
items={[
|
|
|
|
|
|
|
|
{ key: '1', label: 'Option 1' },
|
|
|
|
|
|
|
|
{ key: '2', label: 'Option 1' },
|
|
|
|
|
|
|
|
{ key: '3', label: 'Option 1' },
|
|
|
|
|
|
|
|
{ key: '4', label: 'Option 1' },
|
|
|
|
|
|
|
|
{ key: '5', label: 'Option 1' },
|
|
|
|
|
|
|
|
{ key: '6', label: 'Option 1' },
|
|
|
|
|
|
|
|
{ key: '7', label: 'Option 1' },
|
|
|
|
|
|
|
|
{ key: '8', label: 'Option 1' },
|
|
|
|
|
|
|
|
]}
|
|
|
|
|
|
|
|
mode="horizontal"
|
|
|
|
|
|
|
|
overflowedIndicatorPopupClassName="custom-popover"
|
|
|
|
|
|
|
|
getPopupContainer={(node) => node.parentElement!}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</TriggerMockContext.Provider>,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-menu.ant-menu-light.custom-popover')).toBeTruthy();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|