2016-04-26 11:25:59 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import Vue from 'vue'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								describe('Directive v-show', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  it('should check show value is truthy', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const vm = new Vue({
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      template: '<div><span v-show="foo">hello</span></div>',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      data: { foo: true }
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-12 03:40:50 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }).$mount()
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:36:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    expect(vm.$el.firstChild.style.display).toBe('')
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:25:59 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:32:49 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  it('should check show value is falsy', () => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:25:59 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const vm = new Vue({
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      template: '<div><span v-show="foo">hello</span></div>',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      data: { foo: false }
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-12 03:40:50 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }).$mount()
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:36:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    expect(vm.$el.firstChild.style.display).toBe('none')
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:25:59 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  it('should update show value changed', done => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const vm = new Vue({
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      template: '<div><span v-show="foo">hello</span></div>',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      data: { foo: true }
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-12 03:40:50 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }).$mount()
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:36:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    expect(vm.$el.firstChild.style.display).toBe('')
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:25:59 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    vm.foo = false
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    waitForUpdate(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:36:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(vm.$el.firstChild.style.display).toBe('none')
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:25:59 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      vm.foo = {}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }).then(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:36:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(vm.$el.firstChild.style.display).toBe('')
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:25:59 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      vm.foo = 0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }).then(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:36:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(vm.$el.firstChild.style.display).toBe('none')
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:25:59 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      vm.foo = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }).then(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:36:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(vm.$el.firstChild.style.display).toBe('')
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:25:59 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      vm.foo = null
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }).then(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:36:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(vm.$el.firstChild.style.display).toBe('none')
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:25:59 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      vm.foo = '0'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }).then(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:36:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(vm.$el.firstChild.style.display).toBe('')
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:25:59 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      vm.foo = undefined
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }).then(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:36:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(vm.$el.firstChild.style.display).toBe('none')
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:25:59 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      vm.foo = 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }).then(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:36:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(vm.$el.firstChild.style.display).toBe('')
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-19 01:08:14 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }).then(done)
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-26 11:25:59 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								})
							 |