35 lines
1013 B
TypeScript
35 lines
1013 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { mapOperationPayload } from "../../src/adapters/http/resource-mapper.ts";
|
|
import {
|
|
composeBoundaryMapperRegistry,
|
|
mappingSuccess,
|
|
} from "../../src/contracts/boundary-mapper.ts";
|
|
|
|
describe("platform DTO mapper boundary", () => {
|
|
it("fails closed when no feature mapper was injected", () => {
|
|
expect(mapOperationPayload("UNKNOWN", {})).toEqual({
|
|
ok: false,
|
|
code: "MAPPING_INVARIANT_REJECTED",
|
|
});
|
|
});
|
|
|
|
it("rejects duplicate mapper contributions before installation", () => {
|
|
const mapper = {
|
|
mapperId: "ResourceMapper",
|
|
mapperVersion: 1,
|
|
inputSchemaId: "ResourcePayload",
|
|
outputContractId: "Resource",
|
|
owner: "test",
|
|
maxOutputItems: 1,
|
|
map: (input: unknown) => mappingSuccess(input),
|
|
};
|
|
expect(() =>
|
|
composeBoundaryMapperRegistry([
|
|
{ ResourceMapper: mapper },
|
|
{ ResourceMapper: mapper },
|
|
]),
|
|
).toThrow("duplicate boundary mapper");
|
|
});
|
|
});
|