| 1 | import { describe, expect, it } from "bun:test"; |
| 2 | |
| 3 | import { splitRevision } |
| 4 | |
| 5 | describe("splitRevision", () |
| 6 | const branches = |
| 7 | |
| 8 | it("takes the longest branch the segments start with", |
| 9 | expect(splitRevision(["agent |
| 10 | revision: "agent/dev-utilities", |
| 11 | path: "", |
| 12 | }); |
| 13 | expect( |
| 14 | splitRevision(["agent", |
| 15 | ).toEqual({ revision |
| 16 | expect(splitRevision(["agent |
| 17 | revision: "agent", |
| 18 | path: "src", |
| 19 | }); |
| 20 | }); |
| 21 | |
| 22 | it("reads a revision that already holds its slash, as an encoded link carries it", |
| 23 | expect(splitRevision(["feat/a |
| 24 | revision: "feat/a", |
| 25 | path: "README.md", |
| 26 | }); |
| 27 | }); |
| 28 | |
| 29 | it("falls back to the first segment for a tag or a sha", |
| 30 | expect(splitRevision(["v1.0.0 |
| 31 | revision: "v1.0.0", |
| 32 | path: "src", |
| 33 | }); |
| 34 | expect(splitRevision(["feat |
| 35 | revision: "feat", |
| 36 | path: "b", |
| 37 | }); |
| 38 | }); |
| 39 | |
| 40 | it("names nothing when there are no segments", |
| 41 | expect(splitRevision([], |
| 42 | }); |
| 43 | }); |