import Vue from 'vue'
describe('Directive v-show', () => {
it('should check show value is truthy', () => {
const vm = new Vue({
el: '#app',
template: '
hello
',
data: { foo: true }
})
expect(vm.$el.innerHTML).toBe('hello')
})
it('should check show value is falthy', () => {
const vm = new Vue({
el: '#app',
template: 'hello
',
data: { foo: false }
})
expect(vm.$el.innerHTML).toBe('hello')
})
it('should update show value changed', done => {
const vm = new Vue({
el: '#app',
template: 'hello
',
data: { foo: true }
})
expect(vm.$el.innerHTML).toBe('hello')
vm.foo = false
waitForUpdate(() => {
expect(vm.$el.innerHTML).toBe('hello')
vm.foo = {}
}).then(() => {
expect(vm.$el.innerHTML).toBe('hello')
vm.foo = 0
}).then(() => {
expect(vm.$el.innerHTML).toBe('hello')
vm.foo = []
}).then(() => {
expect(vm.$el.innerHTML).toBe('hello')
vm.foo = null
}).then(() => {
expect(vm.$el.innerHTML).toBe('hello')
vm.foo = '0'
}).then(() => {
expect(vm.$el.innerHTML).toBe('hello')
vm.foo = undefined
}).then(() => {
expect(vm.$el.innerHTML).toBe('hello')
vm.foo = 1
}).then(() => {
expect(vm.$el.innerHTML).toBe('hello')
done()
}).catch(done)
})
})