mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-11-30 02:08:12 +08:00
test(utils): [vue] add refs, size and validator test (#16201)
This commit is contained in:
parent
2ae51ddb35
commit
223d0da28a
11
packages/utils/__tests__/vue/refs.test.ts
Normal file
11
packages/utils/__tests__/vue/refs.test.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { composeRefs } from '../..'
|
||||
|
||||
describe('composeRefs', () => {
|
||||
it('ref setter should be called', () => {
|
||||
const refSetter = vi.fn()
|
||||
const fn = composeRefs(refSetter)
|
||||
fn(null)
|
||||
expect(refSetter).toHaveBeenCalled()
|
||||
})
|
||||
})
|
19
packages/utils/__tests__/vue/size.test.ts
Normal file
19
packages/utils/__tests__/vue/size.test.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { getComponentSize } from '../..'
|
||||
|
||||
describe('vue size', () => {
|
||||
it('default value', () => {
|
||||
const value1 = getComponentSize()
|
||||
const value2 = getComponentSize('default')
|
||||
expect(value1).toBe(32)
|
||||
expect(value2).toBe(32)
|
||||
})
|
||||
it('small value', () => {
|
||||
const value = getComponentSize('small')
|
||||
expect(value).toBe(24)
|
||||
})
|
||||
it('large value', () => {
|
||||
const value = getComponentSize('large')
|
||||
expect(value).toBe(40)
|
||||
})
|
||||
})
|
25
packages/utils/__tests__/vue/validator.test.ts
Normal file
25
packages/utils/__tests__/vue/validator.test.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { isValidComponentSize, isValidDatePickType } from '../..'
|
||||
|
||||
describe('validator', () => {
|
||||
it('isValidComponentSize', () => {
|
||||
expect(isValidComponentSize('')).toBe(true)
|
||||
expect(isValidComponentSize('default')).toBe(true)
|
||||
expect(isValidComponentSize('small')).toBe(true)
|
||||
expect(isValidComponentSize('large')).toBe(true)
|
||||
expect(isValidComponentSize('unknown')).toBe(false)
|
||||
})
|
||||
it('isValidDatePickType', () => {
|
||||
expect(isValidDatePickType('year')).toBe(true)
|
||||
expect(isValidDatePickType('years')).toBe(true)
|
||||
expect(isValidDatePickType('month')).toBe(true)
|
||||
expect(isValidDatePickType('date')).toBe(true)
|
||||
expect(isValidDatePickType('dates')).toBe(true)
|
||||
expect(isValidDatePickType('week')).toBe(true)
|
||||
expect(isValidDatePickType('datetime')).toBe(true)
|
||||
expect(isValidDatePickType('datetimerange')).toBe(true)
|
||||
expect(isValidDatePickType('daterange')).toBe(true)
|
||||
expect(isValidDatePickType('monthrange')).toBe(true)
|
||||
expect(isValidDatePickType('moment')).toBe(false)
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user