- pass a cache scope into `getRenderablePatch` and include resolved theme in DiffPanel cache keys - add a test proving `buildPatchCacheKey` changes when cache scope changes
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildPatchCacheKey } from "./diffRendering";
|
|
|
|
describe("buildPatchCacheKey", () => {
|
|
it("returns a stable cache key for identical content", () => {
|
|
const patch = "diff --git a/a.ts b/a.ts\n+console.log('hello')";
|
|
|
|
expect(buildPatchCacheKey(patch)).toBe(buildPatchCacheKey(patch));
|
|
});
|
|
|
|
it("normalizes outer whitespace before hashing", () => {
|
|
const patch = "diff --git a/a.ts b/a.ts\n+console.log('hello')";
|
|
|
|
expect(buildPatchCacheKey(`\n${patch}\n`)).toBe(buildPatchCacheKey(patch));
|
|
});
|
|
|
|
it("changes when diff content changes", () => {
|
|
const before = "diff --git a/a.ts b/a.ts\n+console.log('hello')";
|
|
const after = "diff --git a/a.ts b/a.ts\n+console.log('hello world')";
|
|
|
|
expect(buildPatchCacheKey(before)).not.toBe(buildPatchCacheKey(after));
|
|
});
|
|
|
|
it("changes when cache scope changes", () => {
|
|
const patch = "diff --git a/a.ts b/a.ts\n+console.log('hello')";
|
|
|
|
expect(buildPatchCacheKey(patch, "diff-panel:light")).not.toBe(
|
|
buildPatchCacheKey(patch, "diff-panel:dark"),
|
|
);
|
|
});
|
|
});
|