Skip to content

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

39 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { isValue, qualifier, searchHref, shortCount, tokens, withIs, withQualifier } from "./search.ts";
5
6test("quoted runs stay whole", () => {
7 assert.deepEqual(tokens('parse "two words" label:"good first issue" x'), ["parse", '"two words"', 'label:"good first issue"', "x"]);
8});
9
10test("a qualifier is read, quotes and all", () => {
11 assert.equal(qualifier("x language:rust", "language"), "rust");
12 assert.equal(qualifier('x label:"good first issue"', "label"), "good first issue");
13 assert.equal(qualifier("x", "language"), null);
14});
15
16test("a filter replaces its qualifier and keeps the rest", () => {
17 assert.equal(withQualifier("parse language:go repo:a/b", "language", "rust"), "parse repo:a/b language:rust");
18 assert.equal(withQualifier("parse language:go", "language", null), "parse");
19 assert.equal(withQualifier("crash", "label", "good first issue"), 'crash label:"good first issue"');
20 assert.equal(withQualifier("x workspace:acme", "org", "beta", ["workspace"]), "x org:beta");
21});
22
23test("is: values of one family replace each other", () => {
24 assert.equal(withIs("crash is:open is:pr", ["open", "closed", "merged"], "closed"), "crash is:pr is:closed");
25 assert.equal(withIs("crash is:open", ["open", "closed"], null), "crash");
26 assert.equal(isValue("crash is:Closed", ["open", "closed"]), "closed");
27 assert.equal(isValue("crash", ["open", "closed"]), null);
28});
29
30test("addresses carry the query, the tab and the page", () => {
31 assert.equal(searchHref(" fn main ", "code"), "/search?q=fn+main&type=code");
32 assert.equal(searchHref("x", null, 3), "/search?q=x&page=3");
33 assert.equal(searchHref("x", "items", 1), "/search?q=x&type=items");
34});
35
36test("counts stop at the cap", () => {
37 assert.equal(shortCount(12), "12");
38 assert.equal(shortCount(1000), "1k+");
39});