Skip to content

Commit b704afe

Browse files
test(children.spec.js): Added a test checking for the duplicate keys warning in the case of patchVno
This test cover the case that a empty div changes to a div with children with repeated keys after initial load (see issue vuejs#8832). test vuejs#8832
1 parent 20b4615 commit b704afe

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/unit/modules/vdom/patch/children.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,4 +530,16 @@ describe('vdom patch: children', () => {
530530
patch(vnode2, vnode3)
531531
expect(`Duplicate keys detected: 'b'`).toHaveBeenWarned()
532532
})
533+
534+
it('should warn with duplicate keys: patchVnode with empty oldVnode', () => {
535+
function makeNode (key) {
536+
return new VNode('li', { key: key })
537+
}
538+
539+
const vnode1 = new VNode('div')
540+
const vnode2 = new VNode('div', undefined, ['1', '2', '3', '4', '4'].map(makeNode))
541+
542+
patch(vnode1, vnode2)
543+
expect(`Duplicate keys detected: '4'`).toHaveBeenWarned()
544+
})
533545
})

0 commit comments

Comments
 (0)