import React from 'react'; import { mount } from 'enzyme'; import Dropdown from '..'; import Menu from '../../menu'; import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; import { sleep } from '../../../tests/utils'; describe('Dropdown', () => { mountTest(() => ( }> )); rtlTest(() => ( }> )); it('overlay is function and has custom transitionName', () => { const wrapper = mount(
menu
} transitionName="move-up" visible>
, ); expect(wrapper.render()).toMatchSnapshot(); }); it('overlay is string', () => { const wrapper = mount( , ); expect(wrapper.render()).toMatchSnapshot(); }); it('support Menu expandIcon', async () => { const props = { overlay: ( }> foo foo ), visible: true, getPopupContainer: node => node, }; const wrapper = mount( , ); await sleep(500); expect(wrapper.find(Dropdown).find('#customExpandIcon').length).toBe(1); }); it('should warn if use topCenter or bottomCenter', () => { const error = jest.spyOn(console, 'error'); mount(
, ); expect(error).toHaveBeenCalledWith( expect.stringContaining("[antd: Dropdown] You are using 'bottomCenter'"), ); expect(error).toHaveBeenCalledWith( expect.stringContaining("[antd: Dropdown] You are using 'topCenter'"), ); }); });