it('should remove the v-leave class if the leave callback exists', function () { var el = mockEl('css') document.body.appendChild(el) el.style.width = '1px' code = transition(el, -1, function(){}, compiler) code = transition(el, 1, function(){}, compiler) assert.notOk(el.classList.contains(leaveClass)) })
it('should cancel previous unfired timers', function (done) { transition(el, 1, c.change, compiler) assert.strictEqual(el.vue_timeouts.length, 1) transition(el, -1, c.change, compiler) assert.strictEqual(el.vue_timeouts.length, 0) setTimeout(function () { assert.notOk(timerFired) done() }, 0) })
it('should skip if the option is given but the enter/leave func is not defined', function () { var c = mockChange(), compiler = mockCompiler({}), code = transition(mockEl('js'), 1, c.change, compiler) assert.ok(c.called) assert.strictEqual(code, codes.JS_SKIP_E) assert.ok(compiler.attached) c = mockChange() compiler = mockCompiler({}) code = transition(mockEl('js'), -1, c.change, compiler) assert.ok(c.called) assert.strictEqual(code, codes.JS_SKIP_L) assert.ok(compiler.detached) })
it('should skip if transition is not available', function () { var c = mockChange(), compiler = mockCompiler(), code = transition(mockEl('css'), 1, c.change, compiler) assert.ok(c.called) assert.strictEqual(code, codes.CSS_SKIP) assert.ok(compiler.attached) })
it('should skip if no transition is found on the node', function () { var c = mockChange(), compiler = mockCompiler(), code = transition(mockEl(), 1, c.change, compiler) assert.ok(c.called) assert.strictEqual(code, codes.SKIP) assert.ok(compiler.attached) })
it('should skip if correspinding option is not defined', function () { var c = mockChange(), compiler = mockCompiler(), code = transition(mockEl('js'), 1, c.change, compiler) assert.ok(c.called) assert.strictEqual(code, codes.JS_SKIP) assert.ok(compiler.attached) })
it('should call change immediately if el is invisible', function () { var el = mockEl('css'), c = mockChange(), compiler = mockCompiler() code = transition(el, -1, c.change, compiler) assert.ok(c.called) assert.ok(compiler.detached) })
it('should skip if compiler is in init stage', function () { var c = mockChange(), compiler = mockCompiler() compiler.init = true var code = transition(null, 1, c.change, compiler) assert.ok(c.called) assert.strictEqual(code, codes.INIT) assert.ok(compiler.attached) })
it('should add the class before calling changeState()', function () { code = transition(el, 1, c.change, compiler) assert.ok(c.called) })
it('should call the leave function', function () { code = transition(el, -1, c.change, compiler) assert.ok(c.called) })
it('should attach an ontransitionend listener', function () { el.style.width = '1px' code = transition(el, -1, c.change, compiler) assert.ok(typeof el.vue_trans_cb === 'function') })