UNPKG

domain-objects

Version:

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

25 lines 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const DomainEntity_1 = require("../instantiation/DomainEntity"); describe('DomainUniqueShape', () => { it('should accurately extract the unique key shape of an entity', () => { class SeaTurtle extends DomainEntity_1.DomainEntity { } SeaTurtle.unique = ['seawaterSecurityNumber']; // should be correct const uniqueKeysRight = { seawaterSecurityNumber: '821', }; // should be invalid const uniqueKeysWrongName = { // @ts-expect-error - Type 'number' is not assignable to type 'string'.ts(2322) seawaterSecurityNumber: 921, }; // should be invalid const uniqueKeysWrongKey = { // @ts-expect-error - 'saltwaterSecurityNumber' does not exist in type 'DomainUniqueKeyShape<typeof SeaTurtle>'. Did you mean to write 'seawaterSecurityNumber'? ts(2322) saltwaterSecurityNumber: '821', }; }); }); //# sourceMappingURL=DomainUniqueKeyShape.test.js.map