-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
84 lines (78 loc) · 1.98 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const o = require('ospec')
const tagl = require('./tagl')
o.spec('basic usage', () => {
o('without classes', function(done) {
function h(tagname, classes, ...args) {
o(tagname).equals('div')
o(classes).deepEquals([])
o(args).deepEquals([1, 2])
done()
}
const { div } = tagl(h)
div(1, 2)
})
o('with classes', function(done) {
function h(tagname, classes, ...args) {
o(tagname).equals('span')
o(classes).deepEquals(['foo'])
o(args).deepEquals([{}, 'huhu', 'haha'])
done()
}
const { span } = tagl(h)
span.foo({}, 'huhu', 'haha')
})
})
o.spec('global components', () => {
o('without classes', function(done) {
function myComponent() {}
function h(tagname, classes, ...args) {
o(tagname).equals(myComponent)
o(classes).deepEquals([])
o(args).deepEquals([1, 2])
done()
}
t = tagl(h)
t.myCmp = myComponent
const { myCmp } = t
myCmp(1, 2)
})
o('with classes', function(done) {
function myComponent() {}
function h(tagname, classes, ...args) {
o(tagname).equals(myComponent)
o(classes).deepEquals(['foo'])
o(args).deepEquals([{}, 'huhu', 'haha'])
done()
}
t = tagl(h)
t.myCmp = myComponent
const { myCmp } = t
myCmp.foo({}, 'huhu', 'haha')
})
})
o.spec('local components', () => {
o('without classes', function(done) {
function myComponent() {}
function h(tagname, classes, ...args) {
o(tagname).equals(myComponent)
o(classes).deepEquals([])
o(args).deepEquals([1, 2])
done()
}
t = tagl(h)
const myCmp = t(myComponent)
myCmp(1, 2)
})
o('with classes', function(done) {
function myComponent() {}
function h(tagname, classes, ...args) {
o(tagname).equals(myComponent)
o(classes).deepEquals(['foo'])
o(args).deepEquals([{}, 'huhu', 'haha'])
done()
}
t = tagl(h)
const myCmp = t(myComponent)
myCmp.foo({}, 'huhu', 'haha')
})
})