feat: initial commit
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { Fico } from "../src/Fico.js";
|
||||
|
||||
const fico = new Fico();
|
||||
|
||||
describe("Fico roundtrip", () => {
|
||||
it("encode → PNG → decode should preserve data", () => {
|
||||
const input = new TextEncoder().encode("Hello FICO 🚀");
|
||||
|
||||
const png = fico.toPNG(input);
|
||||
const output = fico.fromPNG(png);
|
||||
|
||||
expect(output).toEqual(input);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
import { describe, it } from "vitest";
|
||||
import { writeFileSync } from "fs";
|
||||
import { Fico } from "../src/Fico.js";
|
||||
|
||||
describe("generate png", () => {
|
||||
it("should generate a PNG file", () => {
|
||||
const fico = new Fico();
|
||||
|
||||
const input = new TextEncoder().encode("Hello FICO 🚀");
|
||||
|
||||
const png = fico.toPNG(input);
|
||||
|
||||
writeFileSync("out.png", png);
|
||||
|
||||
// juste vérifier que quelque chose est généré
|
||||
if (!png || png.length === 0) {
|
||||
throw new Error("PNG empty");
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { Fico } from "../src/Fico.js";
|
||||
|
||||
describe("read png", () => {
|
||||
it("should read PNG and recover original data", () => {
|
||||
const fico = new Fico();
|
||||
|
||||
const input = new TextEncoder().encode("Hello FICO 🚀");
|
||||
|
||||
// encode → PNG
|
||||
const png = fico.toPNG(input);
|
||||
|
||||
// PNG → decode
|
||||
const output = fico.fromPNG(png);
|
||||
|
||||
expect(output).toEqual(input);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user