Skip to content

Commit d7cfd34

Browse files
committed
test for waitForData + promise sugar
1 parent 78d4c14 commit d7cfd34

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/unit/specs/pipeline/data.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,39 @@ describe('data', function () {
9292
})
9393
})
9494

95+
it('waitForData + promise sugar', function (done) {
96+
test({
97+
data: {
98+
waitForData: true,
99+
data: function (transition) {
100+
return {
101+
msg: new Promise(function (resolve) {
102+
setTimeout(function () {
103+
resolve(transition.to.params.msg)
104+
}, wait)
105+
})
106+
}
107+
}
108+
}
109+
}, function (router, calls) {
110+
router.go('/data/hello')
111+
assertCalls(calls, ['data.data'])
112+
expect(router.app.$el.textContent).toBe('')
113+
setTimeout(function () {
114+
expect(router.app.$el.textContent).toBe('hello')
115+
router.go('/data/reload')
116+
assertCalls(calls, ['data.data', 'data.data'])
117+
router.app.$nextTick(function () {
118+
expect(router.app.$el.textContent).toBe('loading...')
119+
setTimeout(function () {
120+
expect(router.app.$el.textContent).toBe('reload')
121+
done()
122+
}, wait * 2)
123+
})
124+
}, wait * 2)
125+
})
126+
})
127+
95128
it('promise error', function (done) {
96129
test({
97130
data: {

0 commit comments

Comments
 (0)