Skip to content

Commit 70e531a

Browse files
committed
test removing stale leaving elements
1 parent cf13336 commit 70e531a

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,39 @@ if (!isIE9) {
383383
}).then(done)
384384
})
385385

386+
it('should remove stale leaving elements', done => {
387+
const spy = jasmine.createSpy('afterLeave')
388+
const vm = new Vue({
389+
template: `
390+
<div>
391+
<transition name="test" @after-leave="afterLeave">
392+
<div v-if="ok" class="test">foo</div>
393+
</transition>
394+
</div>
395+
`,
396+
data: { ok: true },
397+
methods: {
398+
afterLeave: spy
399+
}
400+
}).$mount(el)
401+
402+
expect(vm.$el.innerHTML).toBe('<div class="test">foo</div>')
403+
vm.ok = false
404+
waitForUpdate(() => {
405+
expect(vm.$el.children[0].className).toBe('test test-leave test-leave-active')
406+
}).thenWaitFor(duration / 2).then(() => {
407+
vm.ok = true
408+
}).then(() => {
409+
expect(spy).toHaveBeenCalled()
410+
expect(vm.$el.children.length).toBe(1) // should have removed leaving element
411+
expect(vm.$el.children[0].className).toBe('test test-enter test-enter-active')
412+
}).thenWaitFor(nextFrame).then(() => {
413+
expect(vm.$el.children[0].className).toBe('test test-enter-active')
414+
}).thenWaitFor(duration + 10).then(() => {
415+
expect(vm.$el.innerHTML).toBe('<div class="test">foo</div>')
416+
}).then(done)
417+
})
418+
386419
it('transition with v-show', done => {
387420
const vm = new Vue({
388421
template: `

0 commit comments

Comments
 (0)