diff --git a/src/route-contract.spec.ts b/src/route-contract.spec.ts new file mode 100644 index 0000000..1825dac --- /dev/null +++ b/src/route-contract.spec.ts @@ -0,0 +1,32 @@ +import { Lettermint } from './lettermint'; +import type { RouteData } from './types'; + +const base: RouteData = { + id: 'route_1', + project_id: 'project_1', + slug: 'incoming', + name: 'Incoming', + route_type: 'inbound', + is_default: false, + created_at: '2026-10-01T12:00:00Z', + updated_at: '2026-10-01T12:00:00Z', +}; + +describe('inbound route domain contract', () => { + it.each(['incoming.example.com', null, undefined])( + 'keeps a %s domain on the route client', + async (domain) => { + const payload: RouteData = { + ...base, + ...(domain === undefined ? {} : { inbound_route_domain: domain }), + }; + global.fetch = jest + .fn() + .mockResolvedValue({ ok: true, json: async () => payload } as Response); + const result = await Lettermint.api('team-token').routes.retrieve('route_1'); + const typedDomain: string | null | undefined = result.inbound_route_domain; + expect(typedDomain).toBe(domain); + expect(JSON.parse(JSON.stringify(result))).toEqual(payload); + } + ); +}); diff --git a/src/types.ts b/src/types.ts index d3c1d48..9257b4f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -268,6 +268,7 @@ export interface RouteData { "is_default": boolean; "inbound_address"?: string | null; "inbound_mx_hostname"?: string; + "inbound_route_domain"?: string | null; "inbound_domain"?: string | null; "inbound_domain_verified_at"?: string | null; "inbound_spam_threshold"?: number | null;