test(utils): update vue test (#896)

This commit is contained in:
XieZongChen 2021-08-16 20:54:22 -05:00 committed by GitHub
parent 672ed322a3
commit ea25207831
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
import { h, isVNode, VNode } from 'vue'
import { createHoverColor, createPressedColor } from '../color'
import {
call,
@ -7,6 +8,8 @@ import {
keep,
keysOf,
largerSize,
omit,
render,
smallerSize
} from '..'
@ -110,4 +113,32 @@ describe('vue', () => {
expect(keysOf(test).toString()).toBe(['c'].toString())
expect(keysOf(test2).toString()).toBe(['a', 'b', 'd'].toString())
})
it('should work with omit', () => {
const test = { c: 3 }
const test2 = { a: 1, b: 2, d: test }
expect(JSON.stringify(omit(test2, ['a']))).toBe(
JSON.stringify({ b: 2, d: { c: 3 } })
)
expect(JSON.stringify(omit(test2, ['a', 'd']))).toBe(
JSON.stringify({ b: 2 })
)
expect(JSON.stringify(omit(test2, ['b'], { a: 4, b: 5 }))).toBe(
JSON.stringify({ a: 4, d: { c: 3 }, b: 5 })
)
})
it('should work with render', () => {
function testFunction (value: string): VNode {
return h(value, null, { default: () => 'test' })
}
expect(isVNode(render('test'))).toBe(true)
expect(isVNode(render(123))).toBe(true)
expect(isVNode(render(testFunction, 'div'))).toBe(true)
expect(isVNode(render({ a: 1 }))).toBe(false)
expect(render({ a: 1 })).toBe(null)
expect(isVNode(render(['1']))).toBe(false)
expect(render(['1'])).toBe(null)
})
})