8000 test: add test case for #809 · Yellowbox-AU/nativescript-vue@9c0b94f · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c0b94f

Browse files
committed
test: add test case for nativescript-vue#809
1 parent fbdf327 commit 9c0b94f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

__tests__/renderer/ViewNode.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,27 @@ describe('ViewNode', () => {
120120
expect(refNode.nextSibling).toBeFalsy()
121121
})
122122

123+
test('insertBefore sets siblings of both siblings', () => {
124+
let parentNode = new ViewNode()
125+
let firstNode = new ViewNode()
126+
let lastNode = new ViewNode()
127+
let childNode = new ViewNode()
128+
parentNode.childNodes = [firstNode, lastNode]
129+
firstNode.parentNode = parentNode
130+
lastNode.parentNode = parentNode
131+
132+
parentNode.insertBefore(childNode, lastNode)
133+
134+
expect(parentNode.childNodes.length).toBe(3)
135+
expect(childNode.parentNode).toEqual(parentNode)
136+
expect(firstNode.nextSibling).toEqual(childNode)
137+
expect(lastNode.prevSibling).toEqual(childNode)
138+
expect(childNode.prevSibling).toEqual(firstNode)
139+
expect(childNode.nextSibling).toEqual(lastNode)
140+
expect(firstNode.prevSibling).toBeFalsy()
141+
expect(lastNode.nextSibling).toBeFalsy()
142+
})
143+
123144
test('appendChild throws if no childNode is given', () => {
124145
let node = new ViewNode()
125146

0 commit comments

Comments
 (0)
0