test: fix test case

This commit is contained in:
zombiej 2020-09-21 16:38:43 +08:00
parent 8315262804
commit 7f2bdb7569
2 changed files with 14 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';
import { spyElementPrototype } from 'rc-util/lib/test/domHook';
import Popconfirm from '..';
import mountTest from '../../../tests/shared/mountTest';
import { sleep } from '../../../tests/utils';
@ -14,6 +15,12 @@ describe('Popconfirm', () => {
preventDefault: expect.any(Function),
});
beforeAll(() => {
spyElementPrototype(HTMLElement, 'offsetParent', {
get: () => ({}),
});
});
it('should popup Popconfirm dialog', () => {
const onVisibleChange = jest.fn();

View File

@ -1,5 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';
import { spyElementPrototype } from 'rc-util/lib/test/domHook';
import Tooltip from '..';
import Button from '../../button';
import Switch from '../../switch';
@ -15,6 +16,12 @@ describe('Tooltip', () => {
mountTest(Tooltip);
rtlTest(Tooltip);
beforeAll(() => {
spyElementPrototype(HTMLElement, 'offsetParent', {
get: () => ({}),
});
});
it('check `onVisibleChange` arguments', () => {
const onVisibleChange = jest.fn();
const ref = React.createRef();