UNPKG

domain-objects

Version:

A simple, convenient way to represent domain objects, leverage domain knowledge, and add runtime validation in your code base.

43 lines 1.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const test_fns_1 = require("test-fns"); const DomainEntity_1 = require("../../instantiation/DomainEntity"); describe('DomainPivotKey', () => { (0, test_fns_1.given)('a Payer', () => { let PayerRole; (function (PayerRole) { PayerRole["PRODUCER"] = "PRODUCER"; PayerRole["PROVIDER"] = "PROVIDER"; PayerRole["CUSTOMER"] = "CUSTOMER"; })(PayerRole || (PayerRole = {})); class Payer extends DomainEntity_1.DomainEntity { } Payer.unique = ['role', 'exid']; (0, test_fns_1.when)('we pivot the dobj', () => { (0, test_fns_1.then)('it should allow specification of valid keys', () => { const producer = { PRODUCER: 'bert', }; const provider = { PROVIDER: 'bert', }; const customer = { CUSTOMER: 'bert', }; }); (0, test_fns_1.then)('it should block invalid keys ', () => { const cucumber = { // @ts-expect-error: 'CUCUMBER' does not exist in type 'DomainPivotKeyShape<Payer, "role", "exid">'. CUCUMBER: 'bert', }; }); (0, test_fns_1.then)('it should block invalid values ', () => { const customer = { // @ts-expect-error: Type '{ uuid: string; }' is not assignable to type 'string'. CUSTOMER: { uuid: 'xyz' }, }; }); }); }); }); //# sourceMappingURL=DomainPivotKey.test.js.map