You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.4 KiB
45 lines
1.4 KiB
import notification from '..';
|
|
|
|
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));
|
|
|
|
describe('notification', () => {
|
|
afterEach(() => {
|
|
notification.destroy();
|
|
});
|
|
|
|
it('should be able to hide manually', async () => {
|
|
notification.open({
|
|
message: 'Notification Title',
|
|
duration: 0,
|
|
key: '1',
|
|
});
|
|
notification.open({
|
|
message: 'Notification Title',
|
|
duration: 0,
|
|
key: '2',
|
|
});
|
|
expect(document.querySelectorAll('.ant-notification-notice').length).toBe(2);
|
|
notification.close('1');
|
|
await delay(100);
|
|
expect(document.querySelectorAll('.ant-notification-notice').length).toBe(1);
|
|
notification.close('2');
|
|
await delay(100);
|
|
expect(document.querySelectorAll('.ant-notification-notice').length).toBe(0);
|
|
});
|
|
|
|
it('should be able to destroy globally', () => {
|
|
notification.open({
|
|
message: 'Notification Title',
|
|
duration: 0,
|
|
});
|
|
notification.open({
|
|
message: 'Notification Title',
|
|
duration: 0,
|
|
});
|
|
expect(document.querySelectorAll('.ant-notification').length).toBe(1);
|
|
expect(document.querySelectorAll('.ant-notification-notice').length).toBe(2);
|
|
notification.destroy();
|
|
expect(document.querySelectorAll('.ant-notification').length).toBe(0);
|
|
expect(document.querySelectorAll('.ant-notification-notice').length).toBe(0);
|
|
});
|
|
});
|
|
|