Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { toChangeBreakdown } from "./pullRequestChangeBreakdown.ts";
4
5describe("toChangeBreakdown", () => {
6 it("sums line counts per kind", () => {
7 expect(
8 toChangeBreakdown({
9 truncated: false,
10 files: [
11 { path: "src/a.ts", additions: 10, deletions: 2 },
12 { path: "src/b.ts", additions: 5, deletions: 1 },
13 { path: "src/a.test.ts", additions: 40, deletions: 0 },
14 { path: "pnpm-lock.yaml", additions: 300, deletions: 120 },
15 { path: "README.md", additions: 7, deletions: 3 },
16 ],
17 }),
18 ).toEqual({
19 code: { additions: 15, deletions: 3 },
20 tests: { additions: 40, deletions: 0 },
21 mocks: { additions: 0, deletions: 0 },
22 generated: { additions: 300, deletions: 120 },
23 docs: { additions: 7, deletions: 3 },
24 });
25 });
26
27 it("gives no breakdown for a partial file list", () => {
28 expect(
29 toChangeBreakdown({
30 truncated: true,
31 files: [{ path: "src/a.ts", additions: 1, deletions: 0 }],
32 }),
33 ).toBeNull();
34 });
35});