diff --git a/packages/renderer-test/__tests__/testRenderer.spec.ts b/packages/renderer-test/__tests__/testRenderer.spec.ts index f20777a0..bb42ab66 100644 --- a/packages/renderer-test/__tests__/testRenderer.spec.ts +++ b/packages/renderer-test/__tests__/testRenderer.spec.ts @@ -132,16 +132,21 @@ describe('test renderer', () => { { id: 'test' }, - 'hello' + [h('span', 'foo'), 'hello'] ) } } const root = nodeOps.createElement('div') render(h(App), root) - expect(serialize(root)).toEqual(`
hello
`) + expect(serialize(root)).toEqual( + `
foohello
` + ) expect(serialize(root, 2)).toEqual( `
+ + foo + hello
` diff --git a/packages/renderer-test/src/serialize.ts b/packages/renderer-test/src/serialize.ts index ee75b87e..bfc91e66 100644 --- a/packages/renderer-test/src/serialize.ts +++ b/packages/renderer-test/src/serialize.ts @@ -22,10 +22,11 @@ function serializeElement( return `${key}=${JSON.stringify(node.props[key])}` }) .join(' ') + const newLine = indent ? `\n` : `` const children = node.children.length - ? (indent ? `\n` : ``) + - node.children.map(c => serialize(c, indent, depth + 1)) + - (indent ? `\n` : ``) + ? newLine + + node.children.map(c => serialize(c, indent, depth + 1)).join(newLine) + + newLine : `` const padding = indent ? ` `.repeat(indent).repeat(depth) : `` return (