Skip to content

Commit ea110f6

Browse files
committed
feat: add determineSkips tests
1 parent 7b6153a commit ea110f6

2 files changed

Lines changed: 61 additions & 1 deletion

File tree

determine-skips.test.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const { determineSkips } = require("./find-python-projects.js");
2+
3+
describe("determineSkips", () => {
4+
const GLOBAL_KEY = "__GLOBAL__";
5+
6+
it("puts command under the global key when no project is specified", () => {
7+
const input = `
8+
command=test
9+
`;
10+
expect(determineSkips(input)).toEqual({ [GLOBAL_KEY]: ["test"] });
11+
});
12+
13+
it("uses project name as key and command as value when both are provided", () => {
14+
const input = `
15+
project=my_project,command=package
16+
`;
17+
expect(determineSkips(input)).toEqual({ my_project: ["package"] });
18+
});
19+
20+
it("handles multiple lines: global + project", () => {
21+
const input = `
22+
command=test
23+
project=my_project,command=package
24+
`;
25+
expect(determineSkips(input)).toEqual({
26+
[GLOBAL_KEY]: ["test"],
27+
my_project: ["package"],
28+
});
29+
});
30+
31+
it("trims whitespace and ignores empty lines", () => {
32+
const input = `
33+
34+
command= build
35+
36+
project=alpha , command=deploy
37+
38+
`;
39+
expect(determineSkips(input)).toEqual({
40+
[GLOBAL_KEY]: ["build"],
41+
alpha: ["deploy"],
42+
});
43+
});
44+
45+
it("append more entries when the same project appears multiple times", () => {
46+
const input = `
47+
project=alpha,command=build
48+
project=alpha,command=test
49+
`;
50+
expect(determineSkips(input)).toEqual({ alpha: ["build", "test"] });
51+
});
52+
53+
it("falls back to the raw line when neither project nor command is present", () => {
54+
const input = "test";
55+
expect(determineSkips(input)).toEqual({
56+
[GLOBAL_KEY]: ["test"],
57+
});
58+
});
59+
});

find-python-projects.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ const TOML = require("@iarna/toml");
88
const _get = require("lodash/get.js");
99

1010
module.exports = {
11-
run,
11+
determineSkips,
1212
findPythonProjects,
13+
run,
1314
};
1415

1516
const GLOBAL_KEY = "__GLOBAL__"; // reserved key for commands without a project specified

0 commit comments

Comments
 (0)