Release Format Lab 0.1.0
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { findRoutes, properties } from "../../src/lab/catalog";
|
||||
|
||||
describe("format catalog", () => {
|
||||
it("prefers the lower-loss route for selected properties", () => {
|
||||
const routes = findRoutes("data", "json", "xml", [
|
||||
"scalar-types",
|
||||
"nested",
|
||||
"nulls",
|
||||
]);
|
||||
expect(routes[0]?.formats).toEqual(["json", "xml"]);
|
||||
expect(routes[0]?.summary).toMatchObject({
|
||||
"scalar-types": "expected-preserved",
|
||||
nested: "expected-preserved",
|
||||
});
|
||||
expect(
|
||||
routes.find((route) => route.formats.includes("csv"))?.score,
|
||||
).toBeGreaterThan(routes[0]!.score);
|
||||
});
|
||||
|
||||
it("enumerates bounded acyclic routes and identity evidence", () => {
|
||||
const routes = findRoutes(
|
||||
"subtitle",
|
||||
"ass",
|
||||
"srt",
|
||||
properties.subtitle.map((item) => item.id),
|
||||
);
|
||||
expect(routes.length).toBeGreaterThan(0);
|
||||
expect(
|
||||
routes.every(
|
||||
(route) =>
|
||||
route.edges.length <= 4 &&
|
||||
new Set(route.formats).size === route.formats.length,
|
||||
),
|
||||
).toBe(true);
|
||||
expect(findRoutes("image", "png", "png", ["pixels"])[0]).toMatchObject({
|
||||
formats: ["png"],
|
||||
score: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it("does not invent paths between incompatible audio and video families", () => {
|
||||
expect(findRoutes("av", "wav", "mp4", ["audio"])).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user