فهرست منبع

global config tests

Evan You 10 سال پیش
والد
کامیت
4c6ed93a36
3فایلهای تغییر یافته به همراه40 افزوده شده و 2 حذف شده
  1. 2 1
      package.json
  2. 37 0
      test/unit/features/global-api/global-config.spec.js
  3. 1 1
      test/unit/index.js

+ 2 - 1
package.json

@@ -11,7 +11,8 @@
   ],
   ],
   "scripts": {
   "scripts": {
     "dev": "webpack --watch --config build/webpack.dev.config.js",
     "dev": "webpack --watch --config build/webpack.dev.config.js",
-    "dev-with-test": "npm run dev & karma start build/karma.dev.config.js",
+    "dev-test": "karma start build/karma.dev.config.js",
+    "dev-all": "npm run dev-dist & npm run dev-test",
     "test": "npm run unit && npm run e2e",
     "test": "npm run unit && npm run e2e",
     "build": "NODE_ENV=production node build/build.js",
     "build": "NODE_ENV=production node build/build.js",
     "lint": "eslint src build",
     "lint": "eslint src build",

+ 37 - 0
test/unit/features/global-api/global-config.spec.js

@@ -0,0 +1,37 @@
+import Vue from 'vue'
+
+describe('Global config', function () {
+  describe('preserveWhitespace', function () {
+    it('should be true by default', function () {
+      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>')
+    })
+
+    it('should remove whitespaces when set to false', function () {
+      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
+    })
+  })
+
+  describe('silent', function () {
+    it('should be false by default', function () {
+      Vue.util.warn('foo')
+      expect('foo').toHaveBeenWarned()
+    })
+
+    it('should work when set to true', function () {
+      Vue.config.silent = true
+      Vue.util.warn('foo')
+      expect('foo').not.toHaveBeenWarned()
+      Vue.config.silent = false
+    })
+  })
+})

+ 1 - 1
test/unit/index.js

@@ -43,5 +43,5 @@ beforeEach(function () {
 })
 })
 
 
 // require all test files
 // require all test files
-var testsContext = require.context('./specs', true, /\.spec$/)
+var testsContext = require.context('./', true, /\.spec$/)
 testsContext.keys().forEach(testsContext)
 testsContext.keys().forEach(testsContext)