20 lines
700 B
TypeScript
20 lines
700 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { calculateFileSha256 } from "./fileFingerprint";
|
|
|
|
describe("calculateFileSha256", () => {
|
|
it("retourne la même empreinte pour un contenu identique", () => {
|
|
const content = Buffer.from("facture-pdf");
|
|
expect(calculateFileSha256(content)).toBe(calculateFileSha256(Buffer.from(content)));
|
|
});
|
|
|
|
it("distingue deux contenus différents", () => {
|
|
expect(calculateFileSha256(Buffer.from("facture-a"))).not.toBe(
|
|
calculateFileSha256(Buffer.from("facture-b")),
|
|
);
|
|
});
|
|
|
|
it("produit une empreinte SHA-256 hexadécimale", () => {
|
|
expect(calculateFileSha256(Buffer.from("facture"))).toMatch(/^[a-f0-9]{64}$/);
|
|
});
|
|
});
|