Skip to content

Commit 88c6a43

Browse files
authored
test: cover mini-decimal scientific notation fix (#730)
* test: cover mini-decimal scientific notation fix * test: assert scientific notation display value * test: rename jest config back to ts
1 parent fdde44f commit 88c6a43

3 files changed

Lines changed: 12 additions & 16 deletions

File tree

jest.config.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
import { createConfig, type Config } from '@umijs/test';
2-
3-
const defaultConfig = createConfig({
4-
target: 'browser',
5-
jsTransformer: 'swc'
6-
});
7-
8-
const config: Config.InitialOptions = {
9-
...defaultConfig,
10-
setupFiles: [
11-
...defaultConfig.setupFiles,
12-
'./tests/setup.js'
13-
]
1+
module.exports = {
2+
setupFiles: ['./tests/setup.js'],
143
};
15-
16-
export default config;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
]
4646
},
4747
"dependencies": {
48-
"@rc-component/mini-decimal": "^1.0.1",
48+
"@rc-component/mini-decimal": "^1.1.1",
4949
"@rc-component/util": "^1.4.0",
5050
"clsx": "^2.1.1"
5151
},

tests/decimal.test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ describe('InputNumber.Decimal', () => {
6464
expect(container.querySelector('input').value).toEqual('0.1');
6565
});
6666

67+
it('should not crash when scientific notation precision exceeds native toFixed limit', () => {
68+
const expectedValue = `0.${'0'.repeat(306)}1`;
69+
70+
expect(() => {
71+
const { container } = render(<InputNumber defaultValue={1e-307} />);
72+
expect(container.querySelector('input').value).toEqual(expectedValue);
73+
}).not.toThrow();
74+
});
75+
6776
it('custom decimal separator', () => {
6877
const onChange = jest.fn();
6978
const { container } = render(<InputNumber decimalSeparator="," onChange={onChange} />);

0 commit comments

Comments
 (0)