mirror of https://github.com/vuejs/vue.git
				
				
				
			update if tests
This commit is contained in:
		
							parent
							
								
									9b681f7cf0
								
							
						
					
					
						commit
						7169d14179
					
				|  | @ -13,7 +13,7 @@ | |||
|     "dev": "webpack --watch --config build/webpack.dist.dev.config.js", | ||||
|     "dev-test": "karma start build/karma.dev.config.js", | ||||
|     "dev-ssr": "webpack --watch --config build/webpack.ssr.dev.config.js", | ||||
|     "test": "npm run unit && npm run e2e", | ||||
|     "test": "npm run lint && npm run unit && npm run e2e", | ||||
|     "build": "NODE_ENV=production node build/build.js", | ||||
|     "lint": "eslint src build test", | ||||
|     "unit": "karma start build/karma.unit.config.js", | ||||
|  |  | |||
|  | @ -19,7 +19,7 @@ describe('Directive v-if', () => { | |||
|     expect(vm.$el.innerHTML).toBe('') | ||||
|   }) | ||||
| 
 | ||||
|   it('should update if value changed', (done) => { | ||||
|   it('should update if value changed', done => { | ||||
|     const vm = new Vue({ | ||||
|       el: '#app', | ||||
|       template: '<div><span v-if="foo">hello</span></div>', | ||||
|  | @ -57,10 +57,15 @@ describe('Directive v-if', () => { | |||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|   it('should work well with v-else', (done) => { | ||||
|   it('should work well with v-else', done => { | ||||
|     const vm = new Vue({ | ||||
|       el: '#app', | ||||
|       template: '<div><span v-if="foo">hello</span><span v-else>bye</span></div>', | ||||
|       template: ` | ||||
|         <div> | ||||
|           <span v-if="foo">hello</span> | ||||
|           <span v-else>bye</span> | ||||
|         </div> | ||||
|       `,
 | ||||
|       data: { foo: true } | ||||
|     }) | ||||
|     expect(vm.$el.innerHTML).toBe('<span>hello</span>') | ||||
|  | @ -95,11 +100,21 @@ describe('Directive v-if', () => { | |||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|   it('should work well with v-for', (done) => { | ||||
|   it('should work well with v-for', done => { | ||||
|     const vm = new Vue({ | ||||
|       el: '#app', | ||||
|       template: '<div><span v-for="item,i in list" v-if="item.value">{{i}}</span></div>', | ||||
|       data: {list: [{value: true}, {value: false}, {value: true}]} | ||||
|       template: ` | ||||
|         <div> | ||||
|           <span v-for="item,i in list" v-if="item.value">{{i}}</span> | ||||
|         </div> | ||||
|       `,
 | ||||
|       data: { | ||||
|         list: [ | ||||
|           { value: true }, | ||||
|           { value: false }, | ||||
|           { value: true } | ||||
|         ] | ||||
|       } | ||||
|     }) | ||||
|     expect(vm.$el.innerHTML).toBe('<span>0</span><span>2</span>') | ||||
|     vm.list[0].value = false | ||||
|  | @ -118,11 +133,22 @@ describe('Directive v-if', () => { | |||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|   it('should work well with v-for and v-else', (done) => { | ||||
|   it('should work well with v-for and v-else', done => { | ||||
|     const vm = new Vue({ | ||||
|       el: '#app', | ||||
|       template: '<div><span v-for="item,i in list" v-if="item.value">hello</span><span v-else>bye</span></div>', | ||||
|       data: {list: [{value: true}, {value: false}, {value: true}]} | ||||
|       template: ` | ||||
|         <div> | ||||
|           <span v-for="item,i in list" v-if="item.value">hello</span> | ||||
|           <span v-else>bye</span> | ||||
|         </div> | ||||
|       `,
 | ||||
|       data: { | ||||
|         list: [ | ||||
|           { value: true }, | ||||
|           { value: false }, | ||||
|           { value: true } | ||||
|         ] | ||||
|       } | ||||
|     }) | ||||
|     expect(vm.$el.innerHTML).toBe('<span>hello</span><span>bye</span><span>hello</span>') | ||||
|     vm.list[0].value = false | ||||
|  |  | |||
|  | @ -2,22 +2,23 @@ import Vue from 'vue' | |||
| 
 | ||||
| describe('Global config', () => { | ||||
|   describe('preserveWhitespace', () => { | ||||
|     it('should be true by default', () => { | ||||
|     it('should preserve whitepspaces when set to true', () => { | ||||
|       // this option is set to false during unit tests.
 | ||||
|       Vue.config.preserveWhitespace = true | ||||
|       const vm = new Vue({ | ||||
|         el: document.createElement('div'), | ||||
|         template: '<div><span>hi</span> <span>ha</span></div>' | ||||
|       }) | ||||
|       expect(vm.$el.innerHTML).toBe('<span>hi</span> <span>ha</span>') | ||||
|       Vue.config.preserveWhitespace = false | ||||
|     }) | ||||
| 
 | ||||
|     it('should remove whitespaces when set to false', () => { | ||||
|       Vue.config.preserveWhitespace = false | ||||
|       const vm = new Vue({ | ||||
|         el: document.createElement('div'), | ||||
|         template: '<div><span>hi</span> <span>ha</span></div>' | ||||
|       }) | ||||
|       expect(vm.$el.innerHTML).toBe('<span>hi</span><span>ha</span>') | ||||
|       Vue.config.preserveWhitespace = true | ||||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,3 +1,7 @@ | |||
| import Vue from 'vue' | ||||
| 
 | ||||
| Vue.config.preserveWhitespace = false | ||||
| 
 | ||||
| if (typeof console === 'undefined') { | ||||
|   window.console = { | ||||
|     error: function () {} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue