feat: release Office Tools 0.1.0
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describeOoxmlError } from "../../src/office/ooxml-errors";
|
||||
|
||||
describe("OOXML error descriptions", () => {
|
||||
it("offers an in-memory password retry for supported encryption", () => {
|
||||
const description = describeOoxmlError(
|
||||
Object.assign(new Error("encrypted"), { code: "encrypted" }),
|
||||
);
|
||||
expect(description.passwordRequired).toBe(true);
|
||||
expect(description.message).toContain("password protected");
|
||||
});
|
||||
|
||||
it.each([
|
||||
"unsupported-encryption",
|
||||
"legacy-binary-format",
|
||||
"not-ooxml",
|
||||
"ooxml-resource-limit",
|
||||
"ooxml-decoded-image-limit",
|
||||
"parser-crashed",
|
||||
])("provides a stable safe message for %s", (code) => {
|
||||
const description = describeOoxmlError(
|
||||
Object.assign(new Error("internal diagnostic"), { code }),
|
||||
);
|
||||
expect(description.code).toBe(code);
|
||||
expect(description.passwordRequired).toBe(false);
|
||||
expect(description.message).not.toBe("internal diagnostic");
|
||||
});
|
||||
|
||||
it("retains an ordinary parser message as the fallback", () => {
|
||||
expect(describeOoxmlError(new Error("Malformed package")).message).toBe(
|
||||
"Malformed package",
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user