test: improve coverage
This commit is contained in:
@@ -40,7 +40,7 @@ function shuffle(array: Array<any>) {
|
||||
return array
|
||||
}
|
||||
|
||||
it('should patch previously empty children', () => {
|
||||
test('should patch previously empty children', () => {
|
||||
const root = nodeOps.createElement('div')
|
||||
|
||||
render(h('div', []), root)
|
||||
@@ -50,7 +50,7 @@ it('should patch previously empty children', () => {
|
||||
expect(inner(root)).toBe('<div>hello</div>')
|
||||
})
|
||||
|
||||
it('should patch previously null children', () => {
|
||||
test('should patch previously null children', () => {
|
||||
const root = nodeOps.createElement('div')
|
||||
|
||||
render(h('div'), root)
|
||||
@@ -60,6 +60,15 @@ it('should patch previously null children', () => {
|
||||
expect(inner(root)).toBe('<div>hello</div>')
|
||||
})
|
||||
|
||||
test('array children -> text children', () => {
|
||||
const root = nodeOps.createElement('div')
|
||||
render(h('div', [h('div')]), root)
|
||||
expect(inner(root)).toBe('<div><div></div></div>')
|
||||
|
||||
render(h('div', 'hello'), root)
|
||||
expect(inner(root)).toBe('<div>hello</div>')
|
||||
})
|
||||
|
||||
describe('renderer: keyed children', () => {
|
||||
let root: TestElement
|
||||
let elm: TestElement
|
||||
|
||||
@@ -129,6 +129,20 @@ describe('renderer: fragment', () => {
|
||||
root
|
||||
)
|
||||
expect(serializeInner(root)).toBe(`<div>foo</div>barbaz`)
|
||||
|
||||
render(
|
||||
createVNode(
|
||||
Fragment,
|
||||
null,
|
||||
[
|
||||
createTextVNode('baz'),
|
||||
createVNode('div', null, 'foo', PatchFlags.TEXT)
|
||||
],
|
||||
PatchFlags.UNKEYED_FRAGMENT
|
||||
),
|
||||
root
|
||||
)
|
||||
expect(serializeInner(root)).toBe(`baz<div>foo</div>`)
|
||||
})
|
||||
|
||||
it('patch fragment children (compiler generated, keyed)', () => {
|
||||
|
||||
@@ -690,6 +690,7 @@ const classifyRE = /(?:^|[-_])(\w)/g
|
||||
const classify = (str: string): string =>
|
||||
str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '')
|
||||
|
||||
/* istanbul ignore next */
|
||||
export function formatComponentName(
|
||||
instance: ComponentInternalInstance | null,
|
||||
Component: Component,
|
||||
|
||||
@@ -57,6 +57,7 @@ export function warn(msg: string, ...args: any[]) {
|
||||
)
|
||||
} else {
|
||||
const warnArgs = [`[Vue warn]: ${msg}`, ...args]
|
||||
/* istanbul ignore if */
|
||||
if (
|
||||
trace.length &&
|
||||
// avoid spamming console during tests
|
||||
@@ -99,6 +100,7 @@ function getComponentTrace(): ComponentTraceStack {
|
||||
return normalizedStack
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
function formatTrace(trace: ComponentTraceStack): any[] {
|
||||
const logs: any[] = []
|
||||
trace.forEach((entry, i) => {
|
||||
@@ -122,6 +124,7 @@ function formatTraceEntry({ vnode, recurseCount }: TraceEntry): any[] {
|
||||
: [open + close]
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
function formatProps(props: Data): any[] {
|
||||
const res: any[] = []
|
||||
const keys = Object.keys(props)
|
||||
@@ -136,6 +139,7 @@ function formatProps(props: Data): any[] {
|
||||
|
||||
function formatProp(key: string, value: unknown): any[]
|
||||
function formatProp(key: string, value: unknown, raw: true): any
|
||||
/* istanbul ignore next */
|
||||
function formatProp(key: string, value: unknown, raw?: boolean): any {
|
||||
if (isString(value)) {
|
||||
value = JSON.stringify(value)
|
||||
|
||||
Reference in New Issue
Block a user