mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 03:29:39 +08:00
114fdd9333
* fix: upgrade rc-tooltip lint fail * fix tooltip typescript type * rebase and update snapshots * update tests * change trigger mock export * upgrade rc-trigger * fix type error * upgrade dependencies * update snapshots * upgrade rc-calendar and test use sleep * update snapshots * fix test fail * update snapshots
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import Popover from '..';
|
|
import mountTest from '../../../tests/shared/mountTest';
|
|
import { sleep } from '../../../tests/utils';
|
|
|
|
describe('Popover', () => {
|
|
mountTest(Popover);
|
|
|
|
it('should show overlay when trigger is clicked', async () => {
|
|
const popover = mount(
|
|
<Popover content="console.log('hello world')" title="code" trigger="click">
|
|
<span>show me your code</span>
|
|
</Popover>,
|
|
);
|
|
|
|
expect(popover.instance().getPopupDomNode()).toBe(null);
|
|
|
|
popover.find('span').simulate('click');
|
|
await sleep(100);
|
|
|
|
const popup = popover.instance().getPopupDomNode();
|
|
expect(popup).not.toBe(null);
|
|
expect(popup.className).toContain('ant-popover-placement-top');
|
|
expect(popup.innerHTML).toMatchSnapshot();
|
|
expect(popup.innerHTML).toMatchSnapshot();
|
|
});
|
|
|
|
it('props#overlay do not warn anymore', () => {
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
const overlay = jest.fn();
|
|
mount(
|
|
<Popover content="console.log('hello world')" title="code" trigger="click">
|
|
<span>show me your code</span>
|
|
</Popover>,
|
|
);
|
|
|
|
expect(errorSpy.mock.calls.length).toBe(0);
|
|
expect(overlay).not.toHaveBeenCalled();
|
|
});
|
|
});
|