test(components): [input-number] ensure that length restriction exceptions can be caught (#18988)

fix(components): ensure that length restriction exceptions can be caught
This commit is contained in:
Aaron-zon 2024-11-22 16:02:45 +08:00 committed by GitHub
parent 512d31cb79
commit da7c8cec1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -161,15 +161,21 @@ describe('InputNumber.vue', () => {
})
//fix: #12690
test('maximum is less than the minimum', async () => {
try {
const num = ref(6)
mount(() => <InputNumber v-model={num.value} min={10} max={8} />)
} catch (e: any) {
expect(e).to.be.an('error')
expect(e.message).to.equal(
'[InputNumber] min should not be greater than max.'
)
}
const num = ref(6)
const errorHandler = vi.fn()
mount(() => <InputNumber v-model={num.value} min={10} max={8} />, {
global: {
config: {
errorHandler,
},
},
})
expect(errorHandler).toHaveBeenCalled()
const [error] = errorHandler.mock.calls[0]
expect(error.message).toEqual(
'[InputNumber] min should not be greater than max.'
)
})
describe('precision accuracy 2', () => {