Skip to content

Commit cf13336

Browse files
committed
test transition HOC
1 parent 05ef502 commit cf13336

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/unit/features/transition/transition.spec.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,5 +598,39 @@ if (!isIE9) {
598598
expect(vm.$el.children[0].className).toBe('test')
599599
}).then(done)
600600
})
601+
602+
it('custom transition higher-order component', done => {
603+
const vm = new Vue({
604+
template: '<div><my-transition><div v-if="ok" class="test">foo</div></my-transition></div>',
605+
data: { ok: true },
606+
components: {
607+
'my-transition': {
608+
functional: true,
609+
render (h, { data, children }) {
610+
(data.props || (data.props = {})).name = 'test'
611+
return h('transition', data, children)
612+
}
613+
}
614+
}
615+
}).$mount(el)
616+
617+
// should not apply transition on initial render by default
618+
expect(vm.$el.innerHTML).toBe('<div class="test">foo</div>')
619+
vm.ok = false
620+
waitForUpdate(() => {
621+
expect(vm.$el.children[0].className).toBe('test test-leave test-leave-active')
622+
}).thenWaitFor(nextFrame).then(() => {
623+
expect(vm.$el.children[0].className).toBe('test test-leave-active')
624+
}).thenWaitFor(duration + 10).then(() => {
625+
expect(vm.$el.children.length).toBe(0)
626+
vm.ok = true
627+
}).then(() => {
628+
expect(vm.$el.children[0].className).toBe('test test-enter test-enter-active')
629+
}).thenWaitFor(nextFrame).then(() => {
630+
expect(vm.$el.children[0].className).toBe('test test-enter-active')
631+
}).thenWaitFor(duration + 10).then(() => {
632+
expect(vm.$el.children[0].className).toBe('test')
633+
}).then(done)
634+
})
601635
})
602636
}

0 commit comments

Comments
 (0)