mirror of
https://seed.radicle.dev/rad:z4D5UCArafTzTQpDZNQRuqswh3ury.git
synced 2026-10-24 22:10:34 +08:00
Code review is the app's core workflow and had almost no coverage. A mutation run checked that each test fails when the logic it covers breaks.
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import { expect, test } from "vitest";
|
|
|
|
import { patchContributions } from "@app/lib/patchContributions";
|
|
|
|
import { author, comment, review, revision } from "./support/cobs";
|
|
|
|
const alice = author("alice");
|
|
const bob = author("bob");
|
|
|
|
const revisions = [
|
|
revision({
|
|
id: "r1",
|
|
author: alice,
|
|
discussion: [
|
|
comment({ author: alice }),
|
|
comment({ author: bob }),
|
|
comment({ author: bob }),
|
|
],
|
|
reviews: [
|
|
review({
|
|
author: bob,
|
|
comments: [comment({ author: bob }), comment({ author: alice })],
|
|
}),
|
|
],
|
|
}),
|
|
revision({
|
|
id: "r2",
|
|
author: bob,
|
|
reviews: [review({ author: alice }), review({ author: bob })],
|
|
}),
|
|
];
|
|
|
|
test("counts one person's revisions, comments and reviews", () => {
|
|
expect(patchContributions(revisions, bob.did)).toEqual({
|
|
revisionCount: 1,
|
|
commentCount: 3,
|
|
reviewCount: 2,
|
|
});
|
|
});
|
|
|
|
test("counts comments in revision discussions and in reviews", () => {
|
|
expect(patchContributions(revisions, alice.did)).toEqual({
|
|
revisionCount: 1,
|
|
commentCount: 2,
|
|
reviewCount: 1,
|
|
});
|
|
});
|
|
|
|
test("counts nothing for someone who took no part", () => {
|
|
expect(patchContributions(revisions, author("carol").did)).toEqual({
|
|
revisionCount: 0,
|
|
commentCount: 0,
|
|
reviewCount: 0,
|
|
});
|
|
});
|