49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
/**
|
|
* DTP error-codes spec conformance — registry frozen, every code
|
|
* usable to construct a `DriveTemplateError`, namespaced under `DTP.`.
|
|
*/
|
|
|
|
import { describe, expect, it } from "@suaveplan/testing/runner";
|
|
import { DriveTemplateError, DTP_CODES } from "../src/index.js";
|
|
|
|
describe("DTP_CODES is frozen", () => {
|
|
it("DTP_CODES is frozen", { timeout: 5000 }, () => {
|
|
expect(Object.isFrozen(DTP_CODES)).toBe(true);
|
|
});
|
|
|
|
it("every value namespaced under DTP.", { timeout: 5000 }, () => {
|
|
for (const v of Object.values(DTP_CODES)) {
|
|
expect(v).toMatch(/^DTP\./);
|
|
}
|
|
});
|
|
|
|
it("every code constructs a DriveTemplateError that preserves it", {
|
|
timeout: 5000,
|
|
}, () => {
|
|
for (const code of Object.values(DTP_CODES)) {
|
|
const e = new DriveTemplateError(code, "ok");
|
|
expect(e.code).toBe(code);
|
|
}
|
|
});
|
|
|
|
it("registry contains the eight pipeline + two operational codes", {
|
|
timeout: 5000,
|
|
}, () => {
|
|
const expected = [
|
|
"TEMPLATE_VERSION_UNSUPPORTED",
|
|
"TEMPLATE_EXPIRED",
|
|
"TEMPLATE_STALE",
|
|
"TEMPLATE_REPLAY",
|
|
"TEMPLATE_UNTRUSTED_ISSUER",
|
|
"TEMPLATE_SIG_INVALID",
|
|
"TEMPLATE_TOO_DEEP",
|
|
"TEMPLATE_MALFORMED",
|
|
"CDN_BAD_SIGNATURE",
|
|
"KEY_GRANT_REJECTED",
|
|
] as const;
|
|
for (const k of expected) {
|
|
expect(DTP_CODES).toHaveProperty(k);
|
|
}
|
|
});
|
|
});
|