improve coverage

This commit is contained in:
Evan You 2016-05-29 15:02:03 -04:00
parent 7913a96ccb
commit 563cdba11e
8 changed files with 14 additions and 8 deletions

View File

@ -26,13 +26,6 @@ export function addDirective (
(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) {
const hooks = el.hooks || (el.hooks = {})
const hook = hooks[name]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -62,4 +62,9 @@ describe('Options el', () => {
expect(vm.$el.childNodes[0].getAttribute('fill')).toBe(vm.color)
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()
})
})