From 220ddc39d7eb5613b16c8bb8582b9680e01843c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Fri, 13 Mar 2026 23:53:57 +0800 Subject: [PATCH 1/3] test: cover mini-decimal scientific notation fix --- jest.config.js | 3 +++ jest.config.ts | 16 ---------------- package.json | 2 +- tests/decimal.test.tsx | 4 ++++ 4 files changed, 8 insertions(+), 17 deletions(-) create mode 100644 jest.config.js delete mode 100644 jest.config.ts diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 00000000..5328c18e --- /dev/null +++ b/jest.config.js @@ -0,0 +1,3 @@ +module.exports = { + setupFiles: ['./tests/setup.js'], +}; diff --git a/jest.config.ts b/jest.config.ts deleted file mode 100644 index a81b4f1e..00000000 --- a/jest.config.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { createConfig, type Config } from '@umijs/test'; - -const defaultConfig = createConfig({ - target: 'browser', - jsTransformer: 'swc' -}); - -const config: Config.InitialOptions = { - ...defaultConfig, - setupFiles: [ - ...defaultConfig.setupFiles, - './tests/setup.js' - ] -}; - -export default config; diff --git a/package.json b/package.json index 0cf307c3..39073d39 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ ] }, "dependencies": { - "@rc-component/mini-decimal": "^1.0.1", + "@rc-component/mini-decimal": "^1.1.1", "@rc-component/util": "^1.4.0", "clsx": "^2.1.1" }, diff --git a/tests/decimal.test.tsx b/tests/decimal.test.tsx index 750444f7..0b4830c2 100644 --- a/tests/decimal.test.tsx +++ b/tests/decimal.test.tsx @@ -64,6 +64,10 @@ describe('InputNumber.Decimal', () => { expect(container.querySelector('input').value).toEqual('0.1'); }); + it('should not crash when scientific notation precision exceeds native toFixed limit', () => { + expect(() => render()).not.toThrow(); + }); + it('custom decimal separator', () => { const onChange = jest.fn(); const { container } = render(); From 673f5321bf4930b393951beef629c6262cd641d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Sat, 14 Mar 2026 00:03:17 +0800 Subject: [PATCH 2/3] test: assert scientific notation display value --- tests/decimal.test.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/decimal.test.tsx b/tests/decimal.test.tsx index 0b4830c2..d3f1eb23 100644 --- a/tests/decimal.test.tsx +++ b/tests/decimal.test.tsx @@ -65,7 +65,12 @@ describe('InputNumber.Decimal', () => { }); it('should not crash when scientific notation precision exceeds native toFixed limit', () => { - expect(() => render()).not.toThrow(); + const expectedValue = `0.${'0'.repeat(306)}1`; + + expect(() => { + const { container } = render(); + expect(container.querySelector('input').value).toEqual(expectedValue); + }).not.toThrow(); }); it('custom decimal separator', () => { From 57b7f64eadbf4bf851bb8ffbda2d807b6379d944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Sat, 14 Mar 2026 00:11:22 +0800 Subject: [PATCH 3/3] test: rename jest config back to ts --- jest.config.js => jest.config.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jest.config.js => jest.config.ts (100%) diff --git a/jest.config.js b/jest.config.ts similarity index 100% rename from jest.config.js rename to jest.config.ts