From da7c8cec1db67e8116eb9cd40159aa5bcabab84a Mon Sep 17 00:00:00 2001
From: Aaron-zon <1640485761@qq.com>
Date: Fri, 22 Nov 2024 16:02:45 +0800
Subject: [PATCH] test(components): [input-number] ensure that length
restriction exceptions can be caught (#18988)
fix(components): ensure that length restriction exceptions can be caught
---
.../__tests__/input-number.test.tsx | 24 ++++++++++++-------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/packages/components/input-number/__tests__/input-number.test.tsx b/packages/components/input-number/__tests__/input-number.test.tsx
index 2adcdbb8de..279aeef106 100755
--- a/packages/components/input-number/__tests__/input-number.test.tsx
+++ b/packages/components/input-number/__tests__/input-number.test.tsx
@@ -161,15 +161,21 @@ describe('InputNumber.vue', () => {
})
//fix: #12690
test('maximum is less than the minimum', async () => {
- try {
- const num = ref(6)
- mount(() => )
- } 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(() => , {
+ 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', () => {