fix(cli): validate positive numeric options (#49)

This commit is contained in:
lazyGPT07 2026-06-13 23:55:18 -06:00 committed by GitHub
parent aa3fdba277
commit fbf4d76372
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 37 additions and 8 deletions

View 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");
}
);
});