Skip to content

test: cover mini-decimal scientific notation fix#730

Merged
zombieJ merged 3 commits intomasterfrom
test-scientific-notation-precision
Mar 13, 2026
Merged

test: cover mini-decimal scientific notation fix#730
zombieJ merged 3 commits intomasterfrom
test-scientific-notation-precision

Conversation

@zombieJ
Copy link
Member

@zombieJ zombieJ commented Mar 13, 2026

ref ant-design/ant-design#57152

Summary

  • update @rc-component/mini-decimal to ^1.1.1
  • add a regression test for rendering 1e-307 without crashing
  • switch jest config to a minimal js config so rc-test works after ut update

Testing

  • npm test -- tests/decimal.test.tsx --runInBand
  • npm test -- --runInBand

Summary by CodeRabbit

发布说明

  • 测试

    • 新增数值输入组件在极小值(科学记数法)场景下的稳定性测试,防止渲染或精度处理时崩溃
  • Chores

    • 优化并简化了测试框架的配置
    • 更新了依赖版本以修复或改进数值处理库

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily addresses a potential crash in the InputNumber component when dealing with specific scientific notation values. It achieves this by updating a core dependency that contains the necessary fix and by adding a targeted regression test to prevent future occurrences. Additionally, the project's Jest testing configuration has been streamlined for better maintainability and compatibility.

Highlights

  • Dependency Update: Updated the @rc-component/mini-decimal package to version ^1.1.1 to incorporate a fix for scientific notation handling.
  • Regression Test Added: Introduced a new test case to ensure the InputNumber component does not crash when rendering scientific notation values like 1e-307, specifically addressing precision issues.
  • Jest Configuration Refactor: Switched the Jest configuration from a TypeScript-based setup (jest.config.ts) to a simpler, minimal JavaScript configuration (jest.config.js) to improve compatibility with rc-test.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • jest.config.js
    • Added a new minimal JavaScript-based Jest configuration file.
  • jest.config.ts
    • Removed the previous TypeScript-based Jest configuration file.
  • package.json
    • Updated the @rc-component/mini-decimal dependency from ^1.0.1 to ^1.1.1.
  • tests/decimal.test.tsx
    • Added a new test case to verify that InputNumber does not crash when provided with a defaultValue in scientific notation (e.g., 1e-307).
Activity
  • The pull request was created by zombieJ.
  • The pull request includes an update to a dependency, a new test case, and a configuration file change.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

演练

将 Jest 配置从 TypeScript(jest.config.ts)移除并新增简化的 JavaScript 配置文件(jest.config.js);同时升级 @rc-component/mini-decimal 依赖并新增针对极小数值(1e-307)的 InputNumber 测试用例,确保渲染不抛异常。

变更

Cohort / File(s) Summary
Jest 配置迁移
jest.config.js, jest.config.ts
新增 jest.config.js 导出 { setupFiles: ['./tests/setup.js'] },并删除原有基于 @umijs/testjest.config.ts(包含 createConfig/Config 导入与合并逻辑)。
依赖更新
package.json
@rc-component/mini-decimal 版本从 ^1.0.1 升级到 ^1.1.1
测试用例
tests/decimal.test.tsx
新增/重复添加对极小默认值 1e-307 的测试,渲染 InputNumber 并断言输入值为期望的长小数格式且不抛出异常。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 分钟

诗歌

🐰✨ 我在草地上轻敲键盘,配置换新装,
小数很小也别慌,测试守护夜与光,
依赖跃一阶,组件更稳当,
兔兔跳跃庆一庆,代码更欢畅。

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确地反映了主要变更,即添加测试以覆盖mini-decimal科学记数法修复的回归测试。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test-scientific-notation-precision
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel
Copy link

vercel bot commented Mar 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
input-number Ready Ready Preview, Comment Mar 13, 2026 4:12pm

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.31%. Comparing base (fdde44f) to head (57b7f64).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #730   +/-   ##
=======================================
  Coverage   95.31%   95.31%           
=======================================
  Files           6        6           
  Lines         299      299           
  Branches       82       83    +1     
=======================================
  Hits          285      285           
  Misses         14       14           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates @rc-component/mini-decimal to fix a crash with scientific notation and adds a regression test. The Jest configuration is also updated to a simpler JavaScript-based setup to ensure tests run correctly. The changes are logical and directly address the described issue. I have one suggestion to make the new test case more robust.

});

it('should not crash when scientific notation precision exceeds native toFixed limit', () => {
expect(() => render(<InputNumber defaultValue={1e-307} />)).not.toThrow();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current test correctly verifies that rendering does not crash. However, it could be strengthened by also asserting that a value is actually rendered in the input. This would prevent future regressions where the component might fail silently (e.g., by rendering an empty string) instead of crashing. The suggested change implicitly keeps the crash check, as render would throw an exception and fail the test if it crashed.

    const { container } = render(<InputNumber defaultValue={1e-307} />);
    expect(container.querySelector('input').value).not.toBe('');

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/decimal.test.tsx (1)

67-74: 测试用例设计正确,可选的简化建议。

回归测试逻辑正确,期望值计算准确。不过 Jest 测试中如果有未捕获的异常会自动失败,因此 expect().not.toThrow() 包装器在检测崩溃场景时有些冗余。将其移除可以简化测试结构,并在断言失败时提供更清晰的错误信息。

♻️ 可选的简化方案
 it('should not crash when scientific notation precision exceeds native toFixed limit', () => {
   const expectedValue = `0.${'0'.repeat(306)}1`;

-  expect(() => {
-    const { container } = render(<InputNumber defaultValue={1e-307} />);
-    expect(container.querySelector('input').value).toEqual(expectedValue);
-  }).not.toThrow();
+  const { container } = render(<InputNumber defaultValue={1e-307} />);
+  expect(container.querySelector('input').value).toEqual(expectedValue);
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/decimal.test.tsx` around lines 67 - 74, The test wraps the
render/assert in expect(...).not.toThrow(), which is redundant because Jest will
fail on uncaught exceptions and the wrapper hides clearer failure messages;
update the test in tests/decimal.test.tsx by removing the
expect(...).not.toThrow() wrapper and directly render the InputNumber (using
render(<InputNumber defaultValue={1e-307} />)) then assert that
container.querySelector('input').value === expectedValue so failures surface
clearly; locate symbols InputNumber, expectedValue, and the
container.querySelector('input').value assertion to make the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/decimal.test.tsx`:
- Around line 67-74: The test wraps the render/assert in
expect(...).not.toThrow(), which is redundant because Jest will fail on uncaught
exceptions and the wrapper hides clearer failure messages; update the test in
tests/decimal.test.tsx by removing the expect(...).not.toThrow() wrapper and
directly render the InputNumber (using render(<InputNumber defaultValue={1e-307}
/>)) then assert that container.querySelector('input').value === expectedValue
so failures surface clearly; locate symbols InputNumber, expectedValue, and the
container.querySelector('input').value assertion to make the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 54e3f342-5f1d-4bab-81a0-b6335d28e99f

📥 Commits

Reviewing files that changed from the base of the PR and between 220ddc3 and 673f532.

📒 Files selected for processing (1)
  • tests/decimal.test.tsx

@zombieJ zombieJ merged commit 88c6a43 into master Mar 13, 2026
10 checks passed
@zombieJ zombieJ deleted the test-scientific-notation-precision branch March 13, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant