Files
t3code/apps/mobile/src/features/review/useNativeReviewDiffBridge.test.ts
T
b3e8c0334b T3 Code Mobile [WIP] (#2013)
Co-authored-by: codex <[email protected]>
Co-authored-by: Julius Marminge <[email protected]>
Co-authored-by: Yash Singh <[email protected]>
2026-05-29 17:00:54 -07:00

28 lines
994 B
TypeScript

import { describe, expect, it } from "vitest";
import { buildNativeReviewTokensResetKey, hashReviewDiffKey } from "./useNativeReviewDiffBridge";
describe("native review diff bridge", () => {
it("builds stable reset keys from the rendered diff identity", () => {
const input = {
threadKey: "env:thread",
sectionId: "turn:2",
scheme: "dark" as const,
diff: "diff --git a/a.ts b/a.ts",
fileCount: 1,
rowCount: 4,
};
expect(buildNativeReviewTokensResetKey(input)).toBe(buildNativeReviewTokensResetKey(input));
expect(buildNativeReviewTokensResetKey({ ...input, rowCount: 5 })).not.toBe(
buildNativeReviewTokensResetKey(input),
);
expect(buildNativeReviewTokensResetKey({ ...input, diff: null })).toContain(":empty:");
});
it("includes diff length in the hash key to reduce accidental collisions", () => {
expect(hashReviewDiffKey("abc")).toMatch(/^3:/);
expect(hashReviewDiffKey("abcd")).toMatch(/^4:/);
});
});