-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
65 lines (54 loc) · 2.08 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
var expect = require('chai').expect
, client = require('utilise/client')
, time = require('utilise/time')
, once = require('utilise/once')
, components = require('rijs.components').default
, core = require('rijs.core').default
, fn = require('rijs.fn').default
, delay = require('./').default
, container
, el1, el2
describe('Delay Render', function() {
before(function(){
/* istanbul ignore next */
container = !client
? document.body.firstElementChild
: document.body.appendChild(document.createElement('div'))
})
beforeEach(function(done){
container.innerHTML = ''
container.innerHTML += '<no-delay>'
container.innerHTML += '<ye-delay delay="300">'
el1 = container.children[0]
el2 = container.children[1]
time(30, done)
})
after(function(){
document.body.removeChild(container)
})
it('should postpone rendering by specified time', function(done) {
var ripple = delay(components(fn(core())))
ripple('ye-delay', function(){ this.innerHTML = 'done' })
expect(el2.innerHTML).to.eql('')
time(200, function(){ expect(el2.innerHTML).to.eql('') })
time(400, function(){ expect(el2.innerHTML).to.eql('done') })
time(500, done)
})
it('should not affect delay-less components', function(done) {
var ripple = delay(components(fn(core())))
ripple('no-delay', function(){ this.innerHTML = 'done' })
time(40 , function(){ expect(el1.innerHTML).to.eql('done') })
time(100, done)
})
it('should work in nested custom elements', function(done) {
container.innerHTML = '<x-el></x-el>'
var ripple = delay(components(fn(core())))
time( 10, function(){
ripple('x-el', function(){ once(this)('ye-delay[delay="200"]', 1) })
ripple('ye-delay', function(){ this.innerHTML = 'done' })
})
time(100, function(){ expect(container.innerHTML).to.eql('<x-el><ye-delay inert=""></ye-delay></x-el>') })
time(300, function(){ expect(container.innerHTML).to.eql('<x-el><ye-delay>done</ye-delay></x-el>') })
time(400, done)
})
})