ソースを参照

improve coverage

Evan You 10 年 前
コミット
563cdba11e

+ 0 - 7
src/compiler/helpers.js

@@ -26,13 +26,6 @@ export function addDirective (
   (el.directives || (el.directives = [])).push({ name, value, arg, modifiers })
   (el.directives || (el.directives = [])).push({ name, value, arg, modifiers })
 }
 }
 
 
-export function addStyleBinding (el: ASTElement, name: string, value: string) {
-  const code = `"${name}":${value}`
-  el.styleBinding = el.styleBinding
-    ? el.styleBinding.replace(/}\s?$/, `,${code}}`)
-    : `{${code}}`
-}
-
 export function addHook (el: ASTElement, name: string, code: string) {
 export function addHook (el: ASTElement, name: string, code: string) {
   const hooks = el.hooks || (el.hooks = {})
   const hooks = el.hooks || (el.hooks = {})
   const hook = hooks[name]
   const hook = hooks[name]

+ 1 - 0
src/core/instance/init.js

@@ -29,6 +29,7 @@ export function initMixin (Vue: Class<Component>) {
         vm
         vm
       )
       )
     }
     }
+    /* istanbul ignore else */
     if (process.env.NODE_ENV !== 'production') {
     if (process.env.NODE_ENV !== 'production') {
       initProxy(vm)
       initProxy(vm)
     } else {
     } else {

+ 2 - 0
src/core/observer/index.js

@@ -108,6 +108,8 @@ function protoAugment (target, src: Object) {
 /**
 /**
  * Augment an target Object or Array by defining
  * Augment an target Object or Array by defining
  * hidden properties.
  * hidden properties.
+ *
+ * istanbul ignore next
  */
  */
 function copyAugment (target: Object, src: Object, keys: Array<string>) {
 function copyAugment (target: Object, src: Object, keys: Array<string>) {
   for (let i = 0, l = keys.length; i < l; i++) {
   for (let i = 0, l = keys.length; i < l; i++) {

+ 1 - 1
src/core/util/env.js

@@ -39,7 +39,7 @@ export const nextTick = (function () {
     }
     }
   }
   }
 
 
-  /* istanbul ignore if */
+  /* istanbul ignore else */
   if (typeof MutationObserver !== 'undefined' && !(isWechat && isIos)) {
   if (typeof MutationObserver !== 'undefined' && !(isWechat && isIos)) {
     let counter = 1
     let counter = 1
     const observer = new MutationObserver(nextTickHandler)
     const observer = new MutationObserver(nextTickHandler)

+ 1 - 0
src/platforms/web/runtime/directives/model.js

@@ -36,6 +36,7 @@ export default {
         el.addEventListener('compositionstart', onCompositionStart)
         el.addEventListener('compositionstart', onCompositionStart)
         el.addEventListener('compositionend', onCompositionEnd)
         el.addEventListener('compositionend', onCompositionEnd)
       }
       }
+      /* istanbul ignore if */
       if (isIE9) {
       if (isIE9) {
         el.vmodel = true
         el.vmodel = true
       }
       }

+ 2 - 0
src/platforms/web/util/class.js

@@ -34,6 +34,7 @@ function genClassFromData (data: Object): string {
   if (staticClass || dynamicClass) {
   if (staticClass || dynamicClass) {
     return concat(staticClass, stringifyClass(dynamicClass))
     return concat(staticClass, stringifyClass(dynamicClass))
   }
   }
+  /* istanbul ignore next */
   return ''
   return ''
 }
 }
 
 
@@ -66,5 +67,6 @@ export function stringifyClass (value: any): string {
     }
     }
     return res.slice(0, -1)
     return res.slice(0, -1)
   }
   }
+  /* istanbul ignore next */
   return res
   return res
 }
 }

+ 2 - 0
src/platforms/web/util/element.js

@@ -66,10 +66,12 @@ export function getTagNamespace (tag: string): ?string {
 
 
 const unknownElementCache = Object.create(null)
 const unknownElementCache = Object.create(null)
 export function isUnknownElement (tag: string): boolean {
 export function isUnknownElement (tag: string): boolean {
+  /* istanbul ignore if */
   if (!inBrowser) {
   if (!inBrowser) {
     return true
     return true
   }
   }
   tag = tag.toLowerCase()
   tag = tag.toLowerCase()
+  /* istanbul ignore if */
   if (unknownElementCache[tag] != null) {
   if (unknownElementCache[tag] != null) {
     return unknownElementCache[tag]
     return unknownElementCache[tag]
   }
   }

+ 5 - 0
test/unit/features/options/el.spec.js

@@ -62,4 +62,9 @@ describe('Options el', () => {
     expect(vm.$el.childNodes[0].getAttribute('fill')).toBe(vm.color)
     expect(vm.$el.childNodes[0].getAttribute('fill')).toBe(vm.color)
     expect(vm.$el.childNodes[0].textContent).toBe(vm.text)
     expect(vm.$el.childNodes[0].textContent).toBe(vm.text)
   })
   })
+
+  it('warn cannot find element', () => {
+    new Vue({ el: '#non-existent' })
+    expect('Cannot find element: #non-existent').toHaveBeenWarned()
+  })
 })
 })