Browse Source

test: update test

pull/2900/head
tangjinzhou 4 years ago
parent
commit
7f7511bf61
  1. 20
      components/notification/__tests__/index.test.js
  2. 7
      components/table/__tests__/Table.filter.test.js

20
components/notification/__tests__/index.test.js

@ -66,7 +66,7 @@ describe('notification', () => {
notification.destroy();
});
it('should be able to open with icon', done => {
it('should be able to open with icon', async () => {
const openNotificationWithIcon = async type => {
const iconPrefix = '.ant-notification-notice-icon';
notification[type]({
@ -78,10 +78,10 @@ describe('notification', () => {
expect(document.querySelectorAll(`${iconPrefix}-${type}`).length).toBe(1);
}, 0);
};
['success', 'info', 'warning', 'error'].forEach(type => {
openNotificationWithIcon(type);
});
done();
await openNotificationWithIcon('success');
await openNotificationWithIcon('info');
await openNotificationWithIcon('warning');
await openNotificationWithIcon('error');
});
it('trigger onClick', () => {
@ -97,27 +97,27 @@ describe('notification', () => {
notification.open({
message: 'Notification Title',
duration: 0,
closeIcon: h => <StepBackwardOutlined />,
closeIcon: <StepBackwardOutlined />,
});
});
await asyncExpect(() => {
expect(document.querySelectorAll('.anticon-step-backward').length).toBe(1);
});
}, 100);
});
it('support config closeIcon', async () => {
notification.config({
closeIcon: h => <StepBackwardOutlined />,
closeIcon: <StepBackwardOutlined />,
});
await asyncExpect(() => {
notification.open({
message: 'Notification Title',
duration: 0,
closeIcon: h => <StepBackwardOutlined />,
closeIcon: <StepBackwardOutlined />,
});
});
await asyncExpect(() => {
expect(document.querySelectorAll('.anticon-step-backward').length).toBe(1);
});
}, 100);
});
});

7
components/table/__tests__/Table.filter.test.js

@ -426,7 +426,7 @@ describe('Table.filter', () => {
expect(renderedNames(wrapper)).toEqual(['Jack']);
});
it('confirm filter when dropdown hidden', async () => {
fit('confirm filter when dropdown hidden', async () => {
const handleChange = jest.fn();
const wrapper = mount(Table, {
...getTableOptions({
@ -452,7 +452,8 @@ describe('Table.filter', () => {
await asyncExpect(() => {
wrapper.find('.ant-dropdown-trigger').trigger('click');
}, 500);
expect(handleChange).toBeCalled();
await asyncExpect(() => {
expect(handleChange).toBeCalled();
}, 0);
});
});

Loading…
Cancel
Save