mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-24 22:01:17 +00:00
test(shared): add unit tests for numeric coercion helper (#98663)
* test(shared): add unit tests for numeric coercion helper * test(shared): cover numeric coercion boundaries --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
18
src/shared/number-coercion.test.ts
Normal file
18
src/shared/number-coercion.test.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveNonNegativeNumber } from "./number-coercion.js";
|
||||
|
||||
describe("resolveNonNegativeNumber", () => {
|
||||
it.each([0, -0, 1.25, Number.MIN_VALUE, Number.MAX_VALUE])(
|
||||
"preserves finite non-negative value %s",
|
||||
(value) => {
|
||||
expect(resolveNonNegativeNumber(value)).toBe(value);
|
||||
},
|
||||
);
|
||||
|
||||
it.each([-1, -0.1, Number.NaN, Infinity, -Infinity, null, undefined])(
|
||||
"rejects invalid value %s",
|
||||
(value) => {
|
||||
expect(resolveNonNegativeNumber(value)).toBeUndefined();
|
||||
},
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user