TypeScript
refactor(web): test file cache identity through its public helpers (#10219)
Julius Marminge88fc41c1b90f
diff --git a/apps/web/src/components/files/fileContentRevision.test.ts b/apps/web/src/components/files/fileContentRevision.test.tsindex e2ec7f9f1ca..4a8bb3d5522 100644--- a/apps/web/src/components/files/fileContentRevision.test.ts+++ b/apps/web/src/components/files/fileContentRevision.test.ts@@ -1,19 +1,11 @@import { describe, expect, it } from "vite-plus/test";-import {- fileContentRevision,- projectFileCacheKey,- projectFileEditorCacheKey,-} from "./fileContentRevision";+import { projectFileCacheKey, projectFileEditorCacheKey } from "./fileContentRevision";-describe("fileContentRevision", () => {+describe("file cache identity", () => {it("changes for same-length edits", () => {- expect(fileContentRevision("nodeVersion")).not.toBe(fileContentRevision("nodeVeasdrs"));- });-- it("keeps identical contents stable", () => {- expect(projectFileCacheKey("/repo", "file.json", "contents")).toBe(- projectFileCacheKey("/repo", "file.json", "contents"),+ expect(projectFileCacheKey("/repo", "file.json", "nodeVersion")).not.toBe(+ projectFileCacheKey("/repo", "file.json", "nodeVeasdrs"),);});diff --git a/apps/web/src/components/files/fileContentRevision.ts b/apps/web/src/components/files/fileContentRevision.tsindex e51d464925b..b4e1698a34d 100644--- a/apps/web/src/components/files/fileContentRevision.ts+++ b/apps/web/src/components/files/fileContentRevision.ts@@ -1,4 +1,4 @@-export function fileContentRevision(contents: string): string {+function fileContentRevision(contents: string): string {let hash = 2_166_136_261;for (let index = 0; index < contents.length; index += 1) {hash ^= contents.charCodeAt(index);