g1t/apps/web/app/lib/branches.test.ts

26 lines990 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { count, drift } from "./branches.ts";
5
6test("a branch two ahead of where main was, with main one further on", () => {
7 // main: m3 m2 m1; the branch left at m2 and added b2 b1.
8 assert.deepEqual(drift(["b2", "b1", "m2", "m1"], ["m3", "m2", "m1"], 50), {
9 ahead: 2,
10 behind: 1,
11 aheadMore: false,
12 behindMore: false,
13 });
14});
15
16test("a branch at main's head is level", () => {
17 assert.deepEqual(drift(["m2", "m1"], ["m2", "m1"], 50), { ahead: 0, behind: 0, aheadMore: false, behindMore: false });
18});
19
20test("a branch with no shared commit in reach says how much it read", () => {
21 assert.deepEqual(drift(["b3", "b2", "b1"], ["m2", "m1"], 3), { ahead: 3, behind: 0, aheadMore: true, behindMore: true });
22 assert.equal(count(3, true), "3+");
23 assert.equal(count(3, false), "3");
An unknown behind count reads ?, not 0+; Code pages leave the description and topics to Files24 // Behind by an unknown number: not "0+", which reads as up to date.
25 assert.equal(count(0, true), "?");
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look26});