vue2/test/unit/features/global-api/config.spec.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-04-24 10:47:54 +08:00
import Vue from 'vue'
2016-04-25 01:29:38 +08:00
describe('Global config', () => {
describe('preserveWhitespace', () => {
2016-04-26 01:17:59 +08:00
it('should preserve whitepspaces when set to true', () => {
// this option is set to false during unit tests.
Vue.config.preserveWhitespace = true
2016-04-24 10:47:54 +08:00
const vm = new Vue({
template: '<div><span>hi</span> <span>ha</span></div>'
}).$mount()
2016-04-24 10:47:54 +08:00
expect(vm.$el.innerHTML).toBe('<span>hi</span> <span>ha</span>')
2016-04-26 01:17:59 +08:00
Vue.config.preserveWhitespace = false
2016-04-24 10:47:54 +08:00
})
2016-04-25 01:29:38 +08:00
it('should remove whitespaces when set to false', () => {
2016-04-24 10:47:54 +08:00
const vm = new Vue({
template: '<div><span>hi</span> <span>ha</span></div>'
}).$mount()
2016-04-24 10:47:54 +08:00
expect(vm.$el.innerHTML).toBe('<span>hi</span><span>ha</span>')
})
})
2016-04-25 01:29:38 +08:00
describe('silent', () => {
it('should be false by default', () => {
2016-04-24 10:47:54 +08:00
Vue.util.warn('foo')
expect('foo').toHaveBeenWarned()
})
2016-04-25 01:29:38 +08:00
it('should work when set to true', () => {
2016-04-24 10:47:54 +08:00
Vue.config.silent = true
Vue.util.warn('foo')
expect('foo').not.toHaveBeenWarned()
Vue.config.silent = false
})
})
})