-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcli.test.ts
More file actions
30 lines (26 loc) · 1.23 KB
/
Copy pathcli.test.ts
File metadata and controls
30 lines (26 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import {parseCliArgs} from "./cli.ts";
import {parseMixedArg} from "./config.ts";
test("recovers swallowed short option clusters", () => {
const single = parseCliArgs(["-T", "-u", "package.json"]);
expect(single.args).toMatchObject({timeout: true, update: true});
expect(single.positionals).toEqual(["package.json"]);
const clustered = parseCliArgs(["-T", "-uj", "package.json"]);
expect(clustered.args).toMatchObject({timeout: true, update: true, json: true});
expect(clustered.positionals).toEqual(["package.json"]);
const {args, positionals} = parseCliArgs(["-i", "-ug", "react", "package.json"]);
expect(args.include).toEqual([]);
expect(parseMixedArg(args.include)).toBe(true);
expect(args.update).toBe(true);
expect(args.greatest).toEqual(["react"]);
expect(positionals).toEqual(["package.json"]);
const ordered = parseCliArgs([
"-g", "-ulreact=*", "-l", "react=<19",
"-g", "-uT1000", "-T", "2000",
"-g", "-ufcluster.json", "-f", "explicit.json",
"package.json",
]);
expect(ordered.args.pin).toEqual(["react=*", "react=<19"]);
expect(ordered.args.timeout).toBe("2000");
expect(ordered.args.file).toEqual(["cluster.json", "explicit.json"]);
expect(ordered.positionals).toEqual(["package.json"]);
});