mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-09-10 19:26:00 +00:00
fix(cli): validate positive numeric options (#49)
This commit is contained in:
parent
aa3fdba277
commit
fbf4d76372
3 changed files with 37 additions and 8 deletions
19
packages/cli/src/numeric-options.test.ts
Normal file
19
packages/cli/src/numeric-options.test.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { parsePositiveInteger } from "./numeric-options.js";
|
||||
|
||||
describe("parsePositiveInteger", () => {
|
||||
it.each([
|
||||
["1", 1],
|
||||
["25", 25],
|
||||
["100", 100]
|
||||
])("parses %s", (value, expected) => {
|
||||
expect(parsePositiveInteger(value)).toBe(expected);
|
||||
});
|
||||
|
||||
it.each(["", " ", "nope", "0", "-1", "1.5", "Infinity", "NaN"])(
|
||||
"rejects invalid input: %s",
|
||||
(value) => {
|
||||
expect(() => parsePositiveInteger(value)).toThrow("must be a positive integer");
|
||||
}
|
||||
);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue