Browse Source

test removing stale leaving elements

dev
Evan You 8 years ago
parent
commit
70e531a3f3
  1. 33
      test/unit/features/transition/transition.spec.js

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

@ -383,6 +383,39 @@ if (!isIE9) {
}).then(done) }).then(done)
}) })
it('should remove stale leaving elements', done => {
const spy = jasmine.createSpy('afterLeave')
const vm = new Vue({
template: `
<div>
<transition name="test" @after-leave="afterLeave">
<div v-if="ok" class="test">foo</div>
</transition>
</div>
`,
data: { ok: true },
methods: {
afterLeave: spy
}
}).$mount(el)
expect(vm.$el.innerHTML).toBe('<div class="test">foo</div>')
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('<div class="test">foo</div>')
}).then(done)
})
it('transition with v-show', done => { it('transition with v-show', done => {
const vm = new Vue({ const vm = new Vue({
template: ` template: `

Loading…
Cancel
Save