From 7f7511bf6118ba24b78f02b2533ab6c7be683a10 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Sun, 20 Sep 2020 23:04:37 +0800 Subject: [PATCH] test: update test --- .../notification/__tests__/index.test.js | 20 +++++++++---------- .../table/__tests__/Table.filter.test.js | 7 ++++--- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/components/notification/__tests__/index.test.js b/components/notification/__tests__/index.test.js index 0da98c9b9..fefadc846 100644 --- a/components/notification/__tests__/index.test.js +++ b/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 => , + closeIcon: , }); }); await asyncExpect(() => { expect(document.querySelectorAll('.anticon-step-backward').length).toBe(1); - }); + }, 100); }); it('support config closeIcon', async () => { notification.config({ - closeIcon: h => , + closeIcon: , }); await asyncExpect(() => { notification.open({ message: 'Notification Title', duration: 0, - closeIcon: h => , + closeIcon: , }); }); await asyncExpect(() => { expect(document.querySelectorAll('.anticon-step-backward').length).toBe(1); - }); + }, 100); }); }); diff --git a/components/table/__tests__/Table.filter.test.js b/components/table/__tests__/Table.filter.test.js index 0d4ecfea4..16702e785 100644 --- a/components/table/__tests__/Table.filter.test.js +++ b/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); }); });