Initial Commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
[ZoneTransfer]
|
||||
ZoneId=3
|
||||
BIN
packages/media/fonts/font-convert/tests/fixtures/test.otf
vendored
Normal file
BIN
packages/media/fonts/font-convert/tests/fixtures/test.otf
vendored
Normal file
Binary file not shown.
BIN
packages/media/fonts/font-convert/tests/fixtures/test.ttf
vendored
Normal file
BIN
packages/media/fonts/font-convert/tests/fixtures/test.ttf
vendored
Normal file
Binary file not shown.
45
packages/media/fonts/font-convert/tests/integration.test.ts
Normal file
45
packages/media/fonts/font-convert/tests/integration.test.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
import { createFontConverter, FontConvertError } from "../src/index.js";
|
||||
|
||||
/**
|
||||
* Integration tests that require a real font binary.
|
||||
* Full real-font round-trip tests live in font-compress roundtrip.test.ts.
|
||||
*/
|
||||
describe("font-convert integration", () => {
|
||||
it("throws FontConvertError on obviously corrupt binary", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
const converter = createFontConverter();
|
||||
const garbage = new Uint8Array(64).fill(0xff);
|
||||
expect(() => converter.convert(garbage)).toThrow(FontConvertError);
|
||||
});
|
||||
|
||||
it("createFontConverter returns converter with convert method", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
const converter = createFontConverter();
|
||||
expect(typeof converter.convert).toBe("function");
|
||||
expect(typeof converter.convertFromParsed).toBe("function");
|
||||
});
|
||||
|
||||
it("FontConvertError preserves Error cause", { timeout: 5000 }, () => {
|
||||
const cause = new Error("root cause");
|
||||
const err = new FontConvertError(
|
||||
"FONT_CONVERT.PARSE_FAILED" as any,
|
||||
"wrapped",
|
||||
{ cause }
|
||||
);
|
||||
expect(err.cause).toBe(cause);
|
||||
});
|
||||
|
||||
it("FontConvertError preserves context when provided", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
const err = new FontConvertError(
|
||||
"FONT_CONVERT.INVALID_OPTIONS" as any,
|
||||
"bad options",
|
||||
{ context: { field: "value" } }
|
||||
);
|
||||
expect(err.context).toEqual({ field: "value" });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user