Skip to content

Commit 0959b17

Browse files
author
Guillaume Chau
committed
test(transition): Transitions cancelled on next frame
Add two tests (enter and leave) that cancels the transitions on v-show
1 parent 6ee6849 commit 0959b17

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,50 @@ if (!isIE9) {
612612
}).then(done)
613613
})
614614

615+
it('leave transition with v-show: cancelled on next frame', done => {
616+
const vm = new Vue({
617+
template: `
618+
<div>
619+
<transition name="test">
620+
<div v-show="ok" class="test">foo</div>
621+
</transition>
622+
</div>
623+
`,
624+
data: { ok: true }
625+
}).$mount(el)
626+
627+
vm.ok = false
628+
waitForUpdate(() => {
629+
vm.ok = true
630+
}).thenWaitFor(nextFrame).then(() => {
631+
expect(vm.$el.children[0].className).toBe('test test-enter-active test-enter-to')
632+
}).thenWaitFor(duration + buffer).then(() => {
633+
expect(vm.$el.children[0].className).toBe('test')
634+
}).then(done)
635+
})
636+
637+
it('enter transition with v-show: cancelled on next frame', done => {
638+
const vm = new Vue({
639+
template: `
640+
<div>
641+
<transition name="test">
642+
<div v-show="ok" class="test">foo</div>
643+
</transition>
644+
</div>
645+
`,
646+
data: { ok: false }
647+
}).$mount(el)
648+
649+
vm.ok = true
650+
waitForUpdate(() => {
651+
vm.ok = false
652+
}).thenWaitFor(nextFrame).then(() => {
653+
expect(vm.$el.children[0].className).toBe('test test-leave-active test-leave-to')
654+
}).thenWaitFor(duration + buffer).then(() => {
655+
expect(vm.$el.children[0].className).toBe('test')
656+
}).then(done)
657+
})
658+
615659
it('animations', done => {
616660
const vm = new Vue({
617661
template: `

0 commit comments

Comments
 (0)