Browse Source

test(runtime-core): fix test for vnode key (#846)

djy0 6 năm trước cách đây
mục cha
commit
bcb750bb3a
1 tập tin đã thay đổi với 5 bổ sung5 xóa
  1. 5 5
      packages/runtime-core/__tests__/vnode.spec.ts

+ 5 - 5
packages/runtime-core/__tests__/vnode.spec.ts

@@ -38,12 +38,12 @@ describe('vnode', () => {
     expect(vnode.props).toBe(null)
   })
 
-  test('valid vnode keys', () => {
-    let vnode
-    for (const key in ['', '1', -1, 0, 1, null]) {
-      vnode = createVNode('div', { key })
-      expect(vnode.key).toBe(key)
+  test('vnode keys', () => {
+    for (const key of ['', 'a', 0, 1, NaN]) {
+      expect(createVNode('div', { key }).key).toBe(key)
     }
+    expect(createVNode('div').key).toBe(null)
+    expect(createVNode('div', { key: undefined }).key).toBe(null)
   })
 
   test('create with class component', () => {