import { describe, expect, it } from "vitest"; import { toSqlLiteral } from "./databaseBackup"; describe("toSqlLiteral", () => { it("sérialise les valeurs primitives de manière importable", () => { expect(toSqlLiteral(null)).toBe("NULL"); expect(toSqlLiteral(undefined)).toBe("NULL"); expect(toSqlLiteral(42.5)).toBe("42.5"); expect(toSqlLiteral(true)).toBe("1"); expect(toSqlLiteral(false)).toBe("0"); }); it("échappe les caractères sensibles d’une chaîne SQL", () => { expect(toSqlLiteral("O'Hara\\facture\nligne")).toBe("'O\\'Hara\\\\facture\\nligne'"); }); it("conserve les données binaires et dates sans conversion ambiguë", () => { expect(toSqlLiteral(Buffer.from([0, 255]))).toBe("X'00ff'"); expect(toSqlLiteral(new Date("2026-08-17T12:34:56.000Z"))).toBe("'2026-08-17 12:34:56.000'"); }); });