|
| 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 | +}); |
0 commit comments