2019-01-12 03:33:27 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import { asyncExpect } from '@/tests/utils';
|
|
|
|
import Popover from '..';
|
2020-03-07 11:45:13 +00:00
|
|
|
import mountTest from '../../../tests/shared/mountTest';
|
2018-06-17 07:57:09 +00:00
|
|
|
|
|
|
|
describe('Popover', () => {
|
2020-08-03 05:54:38 +00:00
|
|
|
mountTest({
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Popover />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
2018-06-17 07:57:09 +00:00
|
|
|
it('should show overlay when trigger is clicked', async () => {
|
2019-01-12 03:33:27 +00:00
|
|
|
const popover = mount(
|
|
|
|
{
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Popover
|
|
|
|
ref="popover"
|
|
|
|
content="console.log('hello world')"
|
|
|
|
title="code"
|
|
|
|
trigger="click"
|
|
|
|
>
|
|
|
|
<span>show me your code</span>
|
|
|
|
</Popover>
|
|
|
|
);
|
|
|
|
},
|
2018-06-17 07:57:09 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
{ sync: false },
|
|
|
|
);
|
2018-06-17 07:57:09 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(popover.vm.$refs.popover.getPopupDomNode()).toBe(null);
|
2018-06-17 07:57:09 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
popover.find('span').trigger('click');
|
|
|
|
}, 0);
|
|
|
|
let popup = null;
|
2018-06-17 07:57:09 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
popup = popover.vm.$refs.popover.getPopupDomNode();
|
|
|
|
expect(popup).not.toBe(null);
|
|
|
|
expect(popup.className).toContain('ant-popover-placement-top');
|
|
|
|
}, 1000);
|
2018-06-17 07:57:09 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(popup.innerHTML).toMatchSnapshot();
|
|
|
|
expect(popup.innerHTML).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
await asyncExpect(() => {});
|
|
|
|
});
|
|
|
|
});
|