Files
radicle-explorer/desktop/tests/unit/patchContributions.test.ts
Rūdolfs Ošiņš 983fff9006 Move everything into desktop/
In preparation for merging radicle-desktop into radicle-gui. It's a pure rename, so git can follow every file across the move.
2026-10-12 08:41:12 +02:00

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,
});
});