-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
56 lines (45 loc) · 1.1 KB
/
test.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
55
56
import test from 'ava';
import jsdom from 'jsdom';
const {JSDOM} = jsdom;
const {window} = new JSDOM('');
const {document} = (new JSDOM('')).window;
global.window = window;
global.document = document;
window.CustomEvent = undefined;
const CE = require('.');
test('should create an instance', t => {
const e = new CE('rainbow');
t.is(e.type, 'rainbow');
t.is(e.bubbles, false);
t.is(e.cancelable, false);
t.is(e.detail, null);
});
test('should create an instance that bubbles', t => {
const e = new CE('rainbow', {
bubbles: true
});
t.is(e.type, 'rainbow');
t.is(e.bubbles, true);
t.is(e.cancelable, false);
t.is(e.detail, null);
});
test('should create an instance that is cancelable', t => {
const e = new CE('rainbow', {
cancelable: true
});
t.is(e.type, 'rainbow');
t.is(e.bubbles, false);
t.is(e.cancelable, true);
t.is(e.detail, null);
});
test('should create an instance that has detail object', t => {
const e = new CE('rainbow', {
detail: {
unicorn: 'fly'
}
});
t.is(e.type, 'rainbow');
t.is(e.bubbles, false);
t.is(e.cancelable, false);
t.is(e.detail.unicorn, 'fly');
});