Browse Source

fix unit tests in Firefox/Safari

dev
Evan You 9 years ago
parent
commit
f550933334
  1. 3
      .eslintrc.js
  2. 4
      test/unit/features/directives/for.spec.js
  3. 12
      test/unit/features/directives/show.spec.js
  4. 10
      test/unit/features/global-api/global-observer-api.spec.js

3
.eslintrc.js

@ -8,6 +8,7 @@ module.exports = {
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'standard/object-curly-even-spacing': [2, 'always', {
objectsInObjects: false
}]
}],
'standard/array-bracket-even-spacing': [2, 'never']
}
}

4
test/unit/features/directives/for.spec.js

@ -10,7 +10,7 @@ describe('Directive v-for', () => {
</div>
`,
data: {
list: [ 'a', 'b', 'c' ]
list: ['a', 'b', 'c']
}
})
expect(vm.$el.innerHTML).toBe('<span>0-a</span><span>1-b</span><span>2-c</span>')
@ -23,7 +23,7 @@ describe('Directive v-for', () => {
vm.list.splice(1, 2)
}).then(() => {
expect(vm.$el.innerHTML).toBe('<span>0-d</span><span>1-d</span>')
vm.list = [ 'x', 'y' ]
vm.list = ['x', 'y']
}).then(() => {
expect(vm.$el.innerHTML).toBe('<span>0-x</span><span>1-y</span>')
done()

12
test/unit/features/directives/show.spec.js

@ -7,7 +7,7 @@ describe('Directive v-show', () => {
template: '<div><span v-show="foo">hello</span></div>',
data: { foo: true }
})
expect(vm.$el.innerHTML).toBe('<span>hello</span>')
expect(vm.$el.innerHTML).toMatch(/<span( style="")?>hello<\/span>/)
})
it('should check show value is falthy', () => {
@ -25,31 +25,31 @@ describe('Directive v-show', () => {
template: '<div><span v-show="foo">hello</span></div>',
data: { foo: true }
})
expect(vm.$el.innerHTML).toBe('<span>hello</span>')
expect(vm.$el.innerHTML).toMatch(/<span( style="")?>hello<\/span>/)
vm.foo = false
waitForUpdate(() => {
expect(vm.$el.innerHTML).toBe('<span style="display: none;">hello</span>')
vm.foo = {}
}).then(() => {
expect(vm.$el.innerHTML).toBe('<span>hello</span>')
expect(vm.$el.innerHTML).toMatch(/<span( style="")?>hello<\/span>/)
vm.foo = 0
}).then(() => {
expect(vm.$el.innerHTML).toBe('<span style="display: none;">hello</span>')
vm.foo = []
}).then(() => {
expect(vm.$el.innerHTML).toBe('<span>hello</span>')
expect(vm.$el.innerHTML).toMatch(/<span( style="")?>hello<\/span>/)
vm.foo = null
}).then(() => {
expect(vm.$el.innerHTML).toBe('<span style="display: none;">hello</span>')
vm.foo = '0'
}).then(() => {
expect(vm.$el.innerHTML).toBe('<span>hello</span>')
expect(vm.$el.innerHTML).toMatch(/<span( style="")?>hello<\/span>/)
vm.foo = undefined
}).then(() => {
expect(vm.$el.innerHTML).toBe('<span style="display: none;">hello</span>')
vm.foo = 1
}).then(() => {
expect(vm.$el.innerHTML).toBe('<span>hello</span>')
expect(vm.$el.innerHTML).toMatch(/<span( style="")?>hello<\/span>/)
done()
}).catch(done)
})

10
test/unit/features/global-api/global-observer-api.spec.js

@ -66,17 +66,17 @@ describe('Global Data Observer API', () => {
it('should delete a key', done => {
const vm = new Vue({
el: document.createElement('div'),
template: '<div>{{x}}</div>',
data: { x: 1 }
template: '<div>{{obj.x}}</div>',
data: { obj: { x: 1 }}
})
expect(vm.$el.innerHTML).toBe('1')
vm.x = 2
vm.obj.x = 2
waitForUpdate(() => {
expect(vm.$el.innerHTML).toBe('2')
Vue.delete(vm, 'x')
Vue.delete(vm.obj, 'x')
}).then(() => {
expect(vm.$el.innerHTML).toBe('')
vm.x = 3
vm.obj.x = 3
}).then(() => {
expect(vm.$el.innerHTML).toBe('')
done()

Loading…
Cancel
Save