Files
FastGPT/packages/global/test/common/math/tools.test.ts
T
Ryo 289da0f7b0 chore: bump pro submodule for hydration stability (#6808)
* sandbox-sync-agent

* refactor: host pro as submodule

* chore: checkpoint host pro restructure

* refactor workspace test layout and startup init

* chore: update next turbopack setup

* chore: snapshot current work before actions fix

* chore: update pro submodule

* chore: point pro submodule url to upstream https

* fix: Dockerfile

* chore: update pro submodule

* ci: support private pro submodule token and skip fork jobs

* fix(ci): build sdk workspace deps before code-sandbox bundle

* fix(app): exclude vitest configs from production typecheck

* fix(app-image): build sdk packages before next build

* fix(ci): align dockerfiles with workspace sdk build flow

* chore(docker): upgrade node20 docker images to node24

* fix(ci): read admin coverage output path in pro test workflow

* fix(app-image): include next-i18next config and locale assets

* chore: update pro submodule

* chore: do not specify branch for submodule

* chore: remove most ts-nocheck sign

* chore: update pro submodule

* chore: remove sandbox-agent-sync package

* chore: do not modify "pushData" file logic

* fix: health check

* chore: restore dev axios proxy state

* fix: test-fastgpt report workflow

* fix: use valid vitest coverage action inputs
2026-04-27 17:44:12 +08:00

36 lines
1009 B
TypeScript

import { describe, expect, it } from 'vitest';
import {
formatNumber,
formatNumber2Million,
formatNumber2Thousand
} from '@fastgpt/global/common/math/tools';
describe('formatNumber', () => {
it('should round with default digit', () => {
expect(formatNumber(1.23456)).toBeCloseTo(1.2346, 4);
expect(formatNumber(1.23454)).toBeCloseTo(1.2345, 4);
});
it('should round with custom digit', () => {
expect(formatNumber(1.23456, 100)).toBeCloseTo(1.23, 2);
});
it('should handle negative numbers', () => {
expect(formatNumber(-1.23456)).toBeCloseTo(-1.2346, 4);
});
});
describe('formatNumber2Million', () => {
it('should round to nearest million', () => {
expect(formatNumber2Million(2_499_999)).toBe(2);
expect(formatNumber2Million(2_500_000)).toBe(3);
});
});
describe('formatNumber2Thousand', () => {
it('should round to nearest thousand', () => {
expect(formatNumber2Thousand(1_499)).toBe(1);
expect(formatNumber2Thousand(1_500)).toBe(2);
});
});