Skip to content

g1t/apps/web/app/lib/opened-by.test.ts

25 lines1,133 bytesCodeBlame
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { madeByG1t, openedBy } from "./opened-by.ts";
5
6const author = { id: "usr_1", username: "syntaqx" };
7
8test("a pull request g1t's agent made in a fork shows g1t, requested by its author", () => {
9 const pull = { agent: "g1t", branch: null, author };
10 assert.equal(madeByG1t(pull), true);
11 assert.deepEqual(openedBy(pull), { name: "g1t", requestedBy: "syntaqx" });
12});
13
14test("anything else shows its author", () => {
15 // Someone's own agent.
16 assert.deepEqual(openedBy({ agent: "claude-code", branch: null, author }), { name: "syntaqx", requestedBy: null });
17 // A branch pushed to the repository, even with g1t named on it.
18 assert.equal(madeByG1t({ agent: "g1t", branch: "fix-login" }), false);
19 assert.deepEqual(openedBy({ agent: "g1t", branch: "fix-login", author }), { name: "syntaqx", requestedBy: null });
20});
21
22test("work g1t started itself names nobody as asking", () => {
23 const pull = { agent: "g1t", branch: null, author: { id: "g1t", username: "g1t" } };
24 assert.deepEqual(openedBy(pull), { name: "g1t", requestedBy: null });
25});