From 70e531a3f33f80fc2b376f3d6b7f5c2cabf87802 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 14 Jul 2016 11:06:22 -0400 Subject: [PATCH] test removing stale leaving elements --- .../features/transition/transition.spec.js | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/unit/features/transition/transition.spec.js b/test/unit/features/transition/transition.spec.js index bce273285..0e1e7fdcd 100644 --- a/test/unit/features/transition/transition.spec.js +++ b/test/unit/features/transition/transition.spec.js @@ -383,6 +383,39 @@ if (!isIE9) { }).then(done) }) + it('should remove stale leaving elements', done => { + const spy = jasmine.createSpy('afterLeave') + const vm = new Vue({ + template: ` +
+ +
foo
+
+
+ `, + data: { ok: true }, + methods: { + afterLeave: spy + } + }).$mount(el) + + expect(vm.$el.innerHTML).toBe('
foo
') + vm.ok = false + waitForUpdate(() => { + expect(vm.$el.children[0].className).toBe('test test-leave test-leave-active') + }).thenWaitFor(duration / 2).then(() => { + vm.ok = true + }).then(() => { + expect(spy).toHaveBeenCalled() + expect(vm.$el.children.length).toBe(1) // should have removed leaving element + expect(vm.$el.children[0].className).toBe('test test-enter test-enter-active') + }).thenWaitFor(nextFrame).then(() => { + expect(vm.$el.children[0].className).toBe('test test-enter-active') + }).thenWaitFor(duration + 10).then(() => { + expect(vm.$el.innerHTML).toBe('
foo
') + }).then(done) + }) + it('transition with v-show', done => { const vm = new Vue({ template: `