flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t/services/projects/src/description.test.ts

30 lines1,361 bytesCodeBlame
1import { test } from "node:test";
2import assert from "node:assert/strict";
3
4import { effectiveDescription, ownDescription } from "./description.ts";
5
6test("a project without its own description shows its repository's, as it is now", () => {
7 assert.deepEqual(effectiveDescription({ description: null, repo_description: "Git for agents" }), {
8 description: "Git for agents",
9 inherited: true,
10 });
11 assert.deepEqual(effectiveDescription({ description: null, repo_description: null }), { description: null, inherited: true });
12 assert.deepEqual(effectiveDescription({ description: null }), { description: null, inherited: true });
13});
14
15test("its own description wins over the repository's", () => {
16 assert.deepEqual(effectiveDescription({ description: "The storefront", repo_description: "Monorepo" }), {
17 description: "The storefront",
18 inherited: false,
19 });
20});
21
22test("a change sets its own, clears back to the repository's, or leaves it", () => {
23 assert.equal(ownDescription("Old", undefined), "Old");
24 assert.equal(ownDescription(null, undefined), null);
25 assert.equal(ownDescription("Old", " New "), "New");
26 assert.equal(ownDescription("Old", ""), null);
27 assert.equal(ownDescription("Old", " "), null);
28 assert.equal(ownDescription("Old", null), null);
29 assert.equal(ownDescription(null, "x".repeat(300))?.length, 200);
30});