37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
createStyleResolver,
|
|
safeOdfTransform,
|
|
} from "../../src/components/odf-viewer-model";
|
|
|
|
describe("OpenDocument fidelity adapters", () => {
|
|
it("inherits default and named styles without exposing raw CSS", () => {
|
|
const resolve = createStyleResolver([
|
|
{
|
|
name: "__default__:paragraph",
|
|
isDefault: true,
|
|
family: "paragraph",
|
|
properties: { "paragraph-properties.fo:color": "#123456" },
|
|
},
|
|
{
|
|
name: "Body",
|
|
family: "paragraph",
|
|
properties: { "paragraph-properties.fo:text-align": "justify" },
|
|
},
|
|
]);
|
|
expect(resolve(undefined, "paragraph")).toMatchObject({ color: "#123456" });
|
|
expect(resolve("Body", "paragraph")).toMatchObject({
|
|
color: "#123456",
|
|
textAlign: "justify",
|
|
});
|
|
});
|
|
|
|
it("converts only a bounded inert drawing-transform subset", () => {
|
|
expect(safeOdfTransform("translate(2cm 3cm) rotate(0.5) scale(2)")).toBe(
|
|
"translate(2cm, 3cm) rotate(0.5rad) scale(2)",
|
|
);
|
|
expect(safeOdfTransform("url(https://example.test)")).toBeUndefined();
|
|
expect(safeOdfTransform("matrix(1 0 0 1 2 3)")).toBeUndefined();
|
|
});
|
|
});
|