Skip to content

Commit

Permalink
test: 更新单元测试
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyh2001 committed May 8, 2024
1 parent 76358b1 commit 661ce51
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/fighting-design/_utils/props/__test__/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { expect, test } from 'vitest'
import { setBooleanProp, setNumberProp, setStringProp, setStringNumberProp } from '..'

test('setBooleanProp', () => {
/**
* @see toStrictEqual https://cn.vitest.dev/api/expect.html#tostrictequal
*/
expect(setBooleanProp(true)).toStrictEqual({ type: Boolean, default: true })
expect(setBooleanProp(false)).toStrictEqual({ type: Boolean, default: false })
expect(setBooleanProp()).toStrictEqual({ type: Boolean, default: false })
})

test('setNumberProp', () => {
expect(setNumberProp(1)).toStrictEqual({ type: Number, default: 1 })
expect(setNumberProp(2)).toStrictEqual({ type: Number, default: 2 })
expect(setNumberProp()).toStrictEqual({ type: Number, default: void 0 })
})

test('setStringProp', () => {
expect(setStringProp('123')).toStrictEqual({ type: String, default: '123' })
})

test('setStringNumberProp', () => {
expect(setStringNumberProp('123')).toStrictEqual({ type: [String, Number], default: '123' })
expect(setStringNumberProp()).toStrictEqual({ type: [String, Number], default: void 0 })
expect(setStringNumberProp(222)).toStrictEqual({ type: [String, Number], default: 222 })
})

0 comments on commit 661ce51

Please sign in to comment.