


















@@ -3,6 +3,7 @@ import { describe, expect, it } from "vitest";
33import {
44collectOption,
55parsePositiveIntOrUndefined,
6+parseStrictPositiveIntOrUndefined,
67resolveActionArgs,
78resolveCommandOptionArgs,
89} from "./helpers.js";
@@ -31,6 +32,27 @@ describe("program helpers", () => {
3132expect(parsePositiveIntOrUndefined(value)).toBe(expected);
3233});
333435+it.each([
36+{ value: undefined, expected: undefined },
37+{ value: null, expected: undefined },
38+{ value: "", expected: undefined },
39+{ value: 5, expected: 5 },
40+{ value: 5.9, expected: undefined },
41+{ value: 0, expected: undefined },
42+{ value: -1, expected: undefined },
43+{ value: Number.NaN, expected: undefined },
44+{ value: "10", expected: 10 },
45+{ value: " 10 ", expected: 10 },
46+{ value: "+10", expected: 10 },
47+{ value: "10ms", expected: undefined },
48+{ value: "1.5", expected: undefined },
49+{ value: "0", expected: undefined },
50+{ value: "nope", expected: undefined },
51+{ value: true, expected: undefined },
52+])("parseStrictPositiveIntOrUndefined(%j)", ({ value, expected }) => {
53+expect(parseStrictPositiveIntOrUndefined(value)).toBe(expected);
54+});
55+3456it("resolveActionArgs returns args when command has arg array", () => {
3557const command = new Command();
3658(command as Command & { args?: string[] }).args = ["one", "two"];
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。