it('render MathML elements with correct namespace', () => { const vm = new Vue({}) const h = vm.$createElement const vnode = h('math', [h('matrix')]) expect(vnode.ns).toBe('math') // should apply ns to children expect(vnode.children[0].ns).toBe('math') // although not explicitly listed, elements nested under <math> // should not be treated as component expect(vnode.children[0].componentOptions).toBeUndefined() })
it('render vnode with basic reserved tag using createElement', () => { const vm = new Vue({ data: { msg: 'hello world' } }) const h = vm.$createElement const vnode = h('p', {}) expect(vnode.tag).toBe('p') expect(vnode.data).toEqual({}) expect(vnode.children).toBeUndefined() expect(vnode.text).toBeUndefined() expect(vnode.elm).toBeUndefined() expect(vnode.ns).toBeUndefined() expect(vnode.context).toEqual(vm) })
it('render vnode with children, including boolean and null type', () => { const vm = new Vue({}) const h = vm.$createElement const vnode = h('p', [h('br'), true, 123, h('br'), 'abc', null]) expect(vnode.children.length).toBe(4) expect(vnode.children[0].tag).toBe('br') expect(vnode.children[1].text).toBe('123') expect(vnode.children[2].tag).toBe('br') expect(vnode.children[3].text).toBe('abc') })
it('render svg elements with correct namespace', () => { const vm = new Vue({}) const h = vm.$createElement const vnode = h('svg', [h('a', [h('foo', [h('bar')])])]) expect(vnode.ns).toBe('svg') // should apply ns to children recursively expect(vnode.children[0].ns).toBe('svg') expect(vnode.children[0].children[0].ns).toBe('svg') expect(vnode.children[0].children[0].children[0].ns).toBe('svg') })
it('render vnode with custom tag using createElement', () => { const vm = new Vue({ data: { msg: 'hello world' } }) const h = vm.$createElement const tag = 'custom-tag' const vnode = h(tag, {}) expect(vnode.tag).toBe('custom-tag') expect(vnode.data).toEqual({}) expect(vnode.children).toBeUndefined() expect(vnode.text).toBeUndefined() expect(vnode.elm).toBeUndefined() expect(vnode.ns).toBeUndefined() expect(vnode.context).toEqual(vm) expect(vnode.componentOptions).toBeUndefined() })
it('render vnode with children, including boolean and null type', () => { const vm = new Vue({}) const h = vm.$createElement const vnode = h('p', [h('br'), true, 123, h('br'), 'abc', null]) expect(vnode.children.length).toBe(4) expect(vnode.children[0].tag).toBe('br') expect(vnode.children[1].text).toBe('123') expect(vnode.children[2].tag).toBe('br') expect(vnode.children[3].text).toBe('abc') })
it('render MathML elements with correct namespace', () => { const vm = new Vue({}) const h = vm.$createElement const vnode = h('math', [h('matrix')]) expect(vnode.ns).toBe('math') // should apply ns to children expect(vnode.children[0].ns).toBe('math') // although not explicitly listed, elements nested under <math> // should not be treated as component expect(vnode.children[0].componentOptions).toBeUndefined() })
it('render vnode with createElement with children', () => { const vm = new Vue({}) const h = vm.$createElement const vnode = h('p', void 0, [h('br'), 'hello world', h('br')]) expect(vnode.children[0].tag).toBe('br') expect(vnode.children[1].text).toBe('hello world') expect(vnode.children[2].tag).toBe('br') })
it('render vnode with createElement with children', () => { const vm = new Vue({}) const h = vm.$createElement const vnode = h('p', void 0, [h('br'), 'hello world', h('br')]) expect(vnode.children[0].tag).toBe('br') expect(vnode.children[1].text).toBe('hello world') expect(vnode.children[2].tag).toBe('br') })
it('render svg elements with correct namespace', () => { const vm = new Vue({}) const h = vm.$createElement const vnode = h('svg', [h('a', [h('foo', [h('bar')])])]) expect(vnode.ns).toBe('svg') // should apply ns to children recursively expect(vnode.children[0].ns).toBe('svg') expect(vnode.children[0].children[0].ns).toBe('svg') expect(vnode.children[0].children[0].children[0].ns).toBe('svg') })
it('render vnode with basic reserved tag using createElement', () => { const vm = new Vue({ data: { msg: 'hello world' } }) const h = vm.$createElement const vnode = h('p', {}) expect(vnode.tag).toBe('p') expect(vnode.data).toEqual({}) expect(vnode.children).toBeUndefined() expect(vnode.text).toBeUndefined() expect(vnode.elm).toBeUndefined() expect(vnode.ns).toBeUndefined() expect(vnode.context).toEqual(vm) })