test: assert vnode invalid key warning for NaN

This commit is contained in:
Evan You 2020-07-08 11:47:01 -04:00
parent 4b5ce8b456
commit 00f6031fbf

View File

@ -11,12 +11,14 @@ import {
transformVNodeArgs
} from '../src/vnode'
import { Data } from '../src/component'
import { ShapeFlags, PatchFlags } from '@vue/shared'
import { ShapeFlags, PatchFlags, mockWarn } from '@vue/shared'
import { h, reactive, isReactive } from '../src'
import { createApp, nodeOps, serializeInner } from '@vue/runtime-test'
import { setCurrentRenderingInstance } from '../src/componentRenderUtils'
describe('vnode', () => {
mockWarn()
test('create with just tag', () => {
const vnode = createVNode('p')
expect(vnode.type).toBe('p')
@ -62,6 +64,7 @@ describe('vnode', () => {
}
expect(createVNode('div').key).toBe(null)
expect(createVNode('div', { key: undefined }).key).toBe(null)
expect(`VNode created with invalid key (NaN)`).toHaveBeenWarned()
})
test('create with class component', () => {