Skip to content

Commit 29f6902

Browse files
committed
coverage
1 parent 0dd158f commit 29f6902

File tree

7 files changed

+33
-3
lines changed

7 files changed

+33
-3
lines changed

src/core/instance/init.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ let uid = 0
1414

1515
export function initMixin (Vue: Class<Component>) {
1616
Vue.prototype._init = function (options?: Object) {
17+
/* istanbul ignore if */
1718
if (process.env.NODE_ENV !== 'production' && config.performance && perf) {
1819
perf.mark('init')
1920
}
@@ -52,6 +53,7 @@ export function initMixin (Vue: Class<Component>) {
5253
initInjections(vm)
5354
callHook(vm, 'created')
5455

56+
/* istanbul ignore if */
5557
if (process.env.NODE_ENV !== 'production' && config.performance && perf) {
5658
vm._name = formatComponentName(vm, false)
5759
perf.mark('init end')

src/core/instance/lifecycle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export function mountComponent (
161161
callHook(vm, 'beforeMount')
162162

163163
let updateComponent
164+
/* istanbul ignore if */
164165
if (process.env.NODE_ENV !== 'production' && config.performance && perf) {
165166
updateComponent = () => {
166167
const name = vm._name

src/core/instance/render.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export function renderMixin (Vue: Class<Component>) {
8080
handleError(e, vm, `render function`)
8181
// return error render result,
8282
// or previous vnode to prevent render error causing blank component
83+
/* istanbul ignore else */
8384
if (process.env.NODE_ENV !== 'production') {
8485
vnode = vm.$options.renderError
8586
? vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e)

src/core/util/debug.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ let formatComponentName
66

77
if (process.env.NODE_ENV !== 'production') {
88
const hasConsole = typeof console !== 'undefined'
9-
const classifyRE = /(?:^|[-_/])(\w)/g
9+
const classifyRE = /(?:^|[-_])(\w)/g
1010
const classify = str => str
1111
.replace(classifyRE, c => c.toUpperCase())
12-
.replace(/-/g, '')
12+
.replace(/[-_]/g, '')
1313

1414
warn = (msg, vm) => {
1515
if (hasConsole && (!config.silent)) {
@@ -35,7 +35,7 @@ if (process.env.NODE_ENV !== 'production') {
3535

3636
return (
3737
(name ? `<${classify(name)}>` : `<Anonymous>`) +
38-
(file && includeFile !== false ? file : '')
38+
(file && includeFile !== false ? ` at ${file}` : '')
3939
)
4040
}
4141

src/core/util/error.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export function handleError (err, vm, type) {
99
if (process.env.NODE_ENV !== 'production') {
1010
warn(`Error in ${type}:`, vm)
1111
}
12+
/* istanbul ignore else */
1213
if (inBrowser && typeof console !== 'undefined') {
1314
console.error(err)
1415
} else {

src/entries/web-runtime-with-compiler.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Vue.prototype.$mount = function (
5656
template = getOuterHTML(el)
5757
}
5858
if (template) {
59+
/* istanbul ignore if */
5960
if (process.env.NODE_ENV !== 'production' && config.performance && perf) {
6061
perf.mark('compile')
6162
}
@@ -68,6 +69,7 @@ Vue.prototype.$mount = function (
6869
options.render = render
6970
options.staticRenderFns = staticRenderFns
7071

72+
/* istanbul ignore if */
7173
if (process.env.NODE_ENV !== 'production' && config.performance && perf) {
7274
perf.mark('compile end')
7375
perf.measure(`${this._name} compile`, 'compile', 'compile end')

test/unit/features/error-handling.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,29 @@ describe('Error handling', () => {
100100
Vue.config.errorHandler = null
101101
}).then(done)
102102
})
103+
104+
it('properly format component names', () => {
105+
const format = Vue.util.formatComponentName
106+
const vm = new Vue()
107+
expect(format(vm)).toBe('<Root>')
108+
109+
vm.$root = null
110+
vm.$options.name = 'hello-there'
111+
expect(format(vm)).toBe('<HelloThere>')
112+
113+
vm.$options.name = null
114+
vm.$options._componentTag = 'foo-bar-1'
115+
expect(format(vm)).toBe('<FooBar1>')
116+
117+
vm.$options._componentTag = null
118+
vm.$options.__file = '/foo/bar/baz/SomeThing.vue'
119+
expect(format(vm)).toBe(`<SomeThing> at ${vm.$options.__file}`)
120+
expect(format(vm, false)).toBe('<SomeThing>')
121+
122+
vm.$options.__file = 'C:\\foo\\bar\\baz\\windows_file.vue'
123+
expect(format(vm)).toBe(`<WindowsFile> at ${vm.$options.__file}`)
124+
expect(format(vm, false)).toBe('<WindowsFile>')
125+
})
103126
})
104127

105128
function createErrorTestComponents () {

0 commit comments

Comments
 (0)