@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 46 lines 1.16 KB
Raw
1 import type { VcsListRefsResult } from "@t3tools/contracts";
2 import { AsyncResult } from "effect/reactivity";
3 import { describe, expect, it } from "vite-plus/test";
4
5 import { isPaginatedBranchesNextPagePending } from "./paginatedBranches";
6
7 const FIRST_PAGE: VcsListRefsResult = {
8 refs: [],
9 isRepo: true,
10 hasPrimaryRemote: true,
11 nextCursor: 100,
12 totalCount: 150,
13 };
14
15 const LAST_PAGE: VcsListRefsResult = {
16 ...FIRST_PAGE,
17 nextCursor: null,
18 };
19
20 describe("paginated branch loading state", () => {
21 it("does not label a first-page background refresh as loading more refs", () => {
22 expect(
23 isPaginatedBranchesNextPagePending([
24 AsyncResult.success(FIRST_PAGE, {
25 waiting: true,
26 }),
27 ]),
28 ).toBe(false);
29 });
30
31 it("only reports loading more while a new cursor has no value", () => {
32 expect(
33 isPaginatedBranchesNextPagePending([
34 AsyncResult.success(FIRST_PAGE),
35 AsyncResult.initial<VcsListRefsResult>(true),
36 ]),
37 ).toBe(true);
38
39 expect(
40 isPaginatedBranchesNextPagePending([
41 AsyncResult.success(FIRST_PAGE),
42 AsyncResult.success(LAST_PAGE),
43 ]),
44 ).toBe(false);
45 });
46 });