test: update fragment tests

This commit is contained in:
Evan You
2019-08-23 15:27:17 -04:00
parent 589d3c2feb
commit fd1fef5502
9 changed files with 343 additions and 194 deletions

View File

@@ -1,5 +1,5 @@
import {
createVNode as h,
h,
render,
nodeOps,
NodeTypes,
@@ -125,7 +125,7 @@ describe('test renderer', () => {
{
id: 'test'
},
[h('span', 0, 'foo'), 'hello']
[h('span', 'foo'), 'hello']
)
}
}

View File

@@ -145,7 +145,8 @@ function insert(child: TestNode, parent: TestElement, ref?: TestNode | null) {
parentNode: parent,
refNode: ref
})
remove(child)
// remove the node first, but don't log it as a REMOVE op
remove(child, false)
if (refIndex === undefined) {
parent.children.push(child)
child.parentNode = parent
@@ -155,14 +156,16 @@ function insert(child: TestNode, parent: TestElement, ref?: TestNode | null) {
}
}
function remove(child: TestNode) {
function remove(child: TestNode, logOp: boolean = true) {
const parent = child.parentNode
if (parent != null) {
logNodeOp({
type: NodeOpTypes.REMOVE,
targetNode: child,
parentNode: parent
})
if (logOp) {
logNodeOp({
type: NodeOpTypes.REMOVE,
targetNode: child,
parentNode: parent
})
}
const i = parent.children.indexOf(child)
if (i > -1) {
parent.children.splice(i, 1)