2026-09-29 14:53:50 +08:00
|
|
|
import { parse } from "@babel/parser";
|
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
|
|
2026-10-07 17:16:58 +08:00
|
|
|
import { fingerprintJavaScriptAst } from "./javascriptAstFingerprint.js";
|
2026-09-29 14:53:50 +08:00
|
|
|
|
|
|
|
|
describe("JavaScript AST fingerprints", () => {
|
|
|
|
|
it("includes complete literal values in the fingerprint", () => {
|
|
|
|
|
const prefix = "x".repeat(1_024);
|
|
|
|
|
const left = parse(`const value = ${JSON.stringify(`${prefix}left`)};`);
|
|
|
|
|
const right = parse(`const value = ${JSON.stringify(`${prefix}right`)};`);
|
|
|
|
|
|
2026-09-29 15:30:43 +08:00
|
|
|
expect(fingerprintJavaScriptAst(left)).not.toBe(
|
|
|
|
|
fingerprintJavaScriptAst(right),
|
2026-09-29 14:53:50 +08:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|