import Vue from 'vue' import { formatComponentName } from 'core/util/debug' describe('Debug utilities', () => { it('properly format component names', () => { const vm = new Vue() expect(formatComponentName(vm)).toBe('') vm.$root = null vm.$options.name = 'hello-there' expect(formatComponentName(vm)).toBe('') vm.$options.name = null vm.$options._componentTag = 'foo-bar-1' expect(formatComponentName(vm)).toBe('') vm.$options._componentTag = null vm.$options.__file = '/foo/bar/baz/SomeThing.vue' expect(formatComponentName(vm)).toBe(` at ${vm.$options.__file}`) expect(formatComponentName(vm, false)).toBe('') vm.$options.__file = 'C:\\foo\\bar\\baz\\windows_file.vue' expect(formatComponentName(vm)).toBe(` at ${vm.$options.__file}`) expect(formatComponentName(vm, false)).toBe('') }) it('generate correct component hierarchy trace', () => { const one = { name: 'one', render: h => h(two) } const two = { name: 'two', render: h => h(three) } const three = { name: 'three' } new Vue({ render: h => h(one) }).$mount() expect( `Failed to mount component: template or render function not defined. found in ---> ` ).toHaveBeenWarned() }) it('generate correct component hierarchy trace (recursive)', () => { let i = 0 const one = { name: 'one', render: h => i++ < 5 ? h(one) : h(two) } const two = { name: 'two', render: h => h(three) } const three = { name: 'three' } new Vue({ render: h => h(one) }).$mount() expect( `Failed to mount component: template or render function not defined. found in ---> ... (5 recursive calls) ` ).toHaveBeenWarned() }) })