mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
test(utils): update vue test (#896)
This commit is contained in:
parent
672ed322a3
commit
ea25207831
@ -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)
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user