import { expect, it } from "vitest"; import { decodeXmlPlistText, XmlPlistTextDecodeError, } from "./propertyListXmlText.js"; it.each([ [ Buffer.from( 'caf\xe9', "latin1", ), "unsupported-encoding", ], [ Buffer.from( '\xff', "latin1", ), "invalid-bytes", ], [Buffer.from([0xff, 0xfe, 0, 0, 0x3c, 0, 0, 0]), "unsupported-encoding"], [Buffer.from([0, 0, 0xfe, 0xff, 0, 0, 0, 0x3c]), "unsupported-encoding"], [ Buffer.from(''), "encoding-mismatch", ], [ Buffer.from(''), "unsupported-encoding", ], [Buffer.from([0xff, 0xfe, 0x3c]), "invalid-bytes"], ] as const)("tags XML decoding failures as %s", (bytes, reason) => { expect(() => decodeXmlPlistText(bytes)).toThrow( expect.objectContaining({ name: "XmlPlistTextDecodeError", reason, } satisfies Partial), ); });