-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.js
67 lines (53 loc) · 1.7 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
var CacheComponent = require('./')
var test = require('tape')
var html = require('bel')
test('cache', (t) => {
t.test('should validate input types', (t) => {
t.plan(1)
var comp = new CacheComponent()
t.throws(comp.render.bind(comp), /_render should be implemented/)
})
t.skip('should render elements', (t) => {
t.plan(3)
function MyComp () {
if (!(this instanceof MyComp)) return new MyComp()
CacheComponent.call(this)
}
MyComp.prototype = Object.create(CacheComponent.prototype)
MyComp.prototype._render = function (name) {
return html`
<div>${name}</div>
`
}
var myComp = new MyComp()
var el1 = myComp.render('mittens')
t.equal(String(el1), '<div>mittens</div>', 'init render success')
var el2 = myComp.render('mittens')
var same1 = el2.isSameNode(el1)
t.equal(same1, true, 'proxy success')
var el3 = myComp.render('scruffles')
t.equal(String(el3), '<div>scruffles</div>', 're-render success')
})
t.skip('should accept a custom compare function', (t) => {
t.plan(2)
function MyComp () {
if (!(this instanceof MyComp)) return new MyComp()
CacheComponent.call(this)
}
MyComp.prototype = Object.create(CacheComponent.prototype)
MyComp.prototype._render = function (name) {
return html`
<div>${name}</div>
`
}
MyComp.prototype._update = function (arg1) {
return arg1 !== 'humans!'
}
var myComp = new MyComp()
var el1 = myComp.render('mittens')
t.equal(String(el1), '<div>mittens</div>', 'init render success')
var el2 = myComp.render('humans!')
var same1 = el2.isSameNode(el1)
t.equal(same1, true, 'proxy success')
})
})