forked from alibaba-fusion/next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex-spec.js
54 lines (42 loc) · 1.27 KB
/
index-spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React from 'react';
import ReactDOM from 'react-dom';
import Enzyme, { mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import assert from 'power-assert';
import Notification from '../../src/notification';
Enzyme.configure({ adapter: new Adapter() });
describe('notification', () => {
const delay = time => new Promise(resolve => setTimeout(resolve, time));
afterEach(() => {
Notification.destroy();
})
it('should render timeout close notification', async () => {
let called = false;
Notification.open({
title: '哈哈',
content: '嘿嘿333',
duration: 100,
onClose: () => {
called = true;
}
});
await delay(500);
assert(called);
});
it('should render normal notification', () => {
let key = Notification.open({});
assert(!key);
key = Notification.open({
title: '哈哈',
content: '嘿嘿'
});
Notification.close(key);
key = Notification.open({
title: '哈哈',
content: '嘿嘿'
});
const dom = document.querySelector('.next-message');
assert(!!dom);
Notification.close(key);
});
})