import {
createBlock,
createVNode,
openBlock,
Comment,
Fragment,
Text,
cloneVNode,
mergeProps,
normalizeVNode
} from '../src/vnode'
import { Data } from '../src/component'
import { ShapeFlags, PatchFlags } from '@vue/shared'
describe('vnode', () => {
test('create with just tag', () => {
const vnode = createVNode('p')
expect(vnode.type).toBe('p')
expect(vnode.props).toBe(null)
})
test('create with tag and props', () => {
const vnode = createVNode('p', {})
expect(vnode.type).toBe('p')
expect(vnode.props).toMatchObject({})
})
test('create with tag, props and children', () => {
const vnode = createVNode('p', {}, ['foo'])
expect(vnode.type).toBe('p')
expect(vnode.props).toMatchObject({})
expect(vnode.children).toMatchObject(['foo'])
})
test('create with 0 as props', () => {
const vnode = createVNode('p', null)
expect(vnode.type).toBe('p')
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('create with class component', () => {
class Component {
$props: any
static __vccOpts = { template: '
' }
}
const vnode = createVNode(Component)
expect(vnode.type).toEqual(Component.__vccOpts)
})
describe('class normalization', () => {
test('string', () => {
const vnode = createVNode('p', { class: 'foo baz' })
expect(vnode.props).toMatchObject({ class: 'foo baz' })
})
test('array', () => {
const vnode = createVNode('p', { class: ['foo', 'baz'] })
expect(vnode.props).toMatchObject({ class: 'foo baz' })
})
test('array