Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

queries.test.ts

29 lines995 Bytes

1import { threadPullRequestKeyOf } from "@t3tools/client-runtime/thread-pull-requests";
2import { filterComposerPullRequestMatches } from "@t3tools/shared/composerPullRequestMatches";
3import { expect, it } from "@effect/vitest";
4​
5it("keeps an older exact PR in the mobile menu ahead of twenty newer substring matches", () => {
6 const exact = {
7 host: "github.com",
8 number: 42,
9 projectId: "project",
10 repository: "example/repo",
11 updatedAt: "2025-01-01",
12 };
13 const recent = Array.from({ length: 25 }, (_, index) => ({
14 ...exact,
15 number: 4200 + index,
16 updatedAt: "2026-01-01",
17 }));
18 const matches = filterComposerPullRequestMatches({
19 keyOf: threadPullRequestKeyOf,
20 entries: [exact, ...recent, exact],
21 projectId: exact.projectId,
22 repository: exact.repository,
23 query: "42",
24 limit: 20,
25 });
26 expect(matches).toHaveLength(20);
27 expect(matches[0]).toEqual(exact);
28 expect(matches.filter((entry) => entry.number === 42)).toHaveLength(1);
29});