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

reviewDiffBridgeKeys.test.ts

27 lines997 Bytes

1import { describe, expect, it } from "vite-plus/test";
2​
3import { buildNativeReviewTokensResetKey, hashReviewDiffKey } from "./reviewDiffBridgeKeys";
4​
5describe("native review diff bridge", () => {
6 it("builds stable reset keys from the rendered diff identity", () => {
7 const input = {
8 threadKey: "env:thread",
9 sectionId: "turn:2",
10 scheme: "dark" as const,
11 diff: "diff --git a/a.ts b/a.ts",
12 fileCount: 1,
13 rowCount: 4,
14 };
15​
16 expect(buildNativeReviewTokensResetKey(input)).toBe(buildNativeReviewTokensResetKey(input));
17 expect(buildNativeReviewTokensResetKey({ ...input, rowCount: 5 })).not.toBe(
18 buildNativeReviewTokensResetKey(input),
19 );
20 expect(buildNativeReviewTokensResetKey({ ...input, diff: null })).toContain(":empty:");
21 });
22​
23 it("includes diff length in the hash key to reduce accidental collisions", () => {
24 expect(hashReviewDiffKey("abc")).toMatch(/^3:/);
25 expect(hashReviewDiffKey("abcd")).toMatch(/^4:/);
26 });
27});