|
|
@@ -0,0 +1,27 @@ |
| 1 |
import { expect, test } from "bun:test"; |
| 2 |
import { sharedRed, sharedRedSays } from "../src/flow/shared_red.ts"; |
| 3 |
|
| 4 |
const r = (pull: number, ...failingTests: string[]) => ({ pull, failingTests }); |
| 5 |
|
| 6 |
test("below the threshold nothing is shared", () => { |
| 7 |
expect(sharedRed([r(1, "a"), r(2, "a")])).toEqual([]); |
| 8 |
expect(sharedRedSays([r(1, "a"), r(2, "a")])).toEqual([]); |
| 9 |
}); |
| 10 |
|
| 11 |
test("at the threshold a test is named with its pulls", () => { |
| 12 |
expect(sharedRed([r(3, "a"), r(1, "a"), r(2, "a", "b")])).toEqual([{ test: "a", pulls: [1, 2, 3] }]); |
| 13 |
}); |
| 14 |
|
| 15 |
test("most pulls first, ties by name", () => { |
| 16 |
const rows = [r(1, "z", "b"), r(2, "z", "b"), r(3, "z", "b"), r(4, "z")]; |
| 17 |
expect(sharedRed(rows).map((s) => s.test)).toEqual(["z", "b"]); |
| 18 |
}); |
| 19 |
|
| 20 |
test("a pull counts once per test", () => { |
| 21 |
expect(sharedRed([r(1, "a", "a"), r(1, "a"), r(2, "a")])).toEqual([]); |
| 22 |
}); |
| 23 |
|
| 24 |
test("says the clash", () => { |
| 25 |
const rows = [r(1, "size"), r(2, "size"), r(3, "size")]; |
| 26 |
expect(sharedRedSays(rows)).toEqual(["size fails on 3 pulls: one clash, re-check together after the fix"]); |
| 27 |
}); |
Sentence says only the count; once wired, a person needs the pull numbers too (s.pulls is right there). Consider appending them in the caller, not here, to keep the issue's wording.