Files
multica/packages/views/editor/utils/hash-string.test.ts
603519d158 MUL-6977: test: remove implementation-only coverage (#7932)
* test: remove implementation-only coverage

Co-authored-by: multica-agent <[email protected]>

* test: remove remaining implementation-only coverage

Co-authored-by: multica-agent <[email protected]>

* test: restore compatibility and fragment navigation coverage

Co-authored-by: multica-agent <[email protected]>

* test: preserve behavioral cleanup contracts

Co-authored-by: multica-agent <[email protected]>

---------

Co-authored-by: Sol-Boy <[email protected]>
Co-authored-by: multica-agent <[email protected]>
2026-09-03 13:23:25 +08:00

19 lines
651 B
TypeScript

// @vitest-environment node
import { describe, expect, it } from "vitest";
import { hashString } from "./hash-string";
describe("hashString", () => {
it("differs for different inputs (collision-resistant enough for contentKey)", () => {
expect(hashString("<p>a</p>")).not.toBe(hashString("<p>b</p>"));
});
it("produces [a-z0-9]+ tokens (safe to inline as a JS string without escaping)", () => {
const token = hashString("<h1>标题 😀</h1>\n<script>alert(1)</script>");
expect(token).toMatch(/^[a-z0-9]+$/);
});
it("hashes empty string without throwing", () => {
expect(hashString("")).toMatch(/^[a-z0-9]+$/);
});
});