domain-objects
Version:
A simple, convenient way to represent domain objects, leverage domain knowledge, and add runtime validation in your code base.
29 lines • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const DomainEntity_1 = require("../instantiation/DomainEntity");
describe('DomainPrimaryKeyShape', () => {
it('should accurately extract the primary key shape of an entity', () => {
class SeaTurtle extends DomainEntity_1.DomainEntity {
}
SeaTurtle.primary = ['uuid'];
SeaTurtle.unique = ['seawaterSecurityNumber'];
// should be correct
const uniqueKeysRight = {
uuid: '821',
};
// should be invalid
const uniqueKeysWrongName = {
// @ts-expect-error - Type 'number' is not assignable to type 'string'.ts(2322)
uuid: 921,
};
// should be invalid
const uniqueKeysWrongKey = {
// @ts-expect-error - 'guid' does not exist in type 'DomainUniqueKeyShape<typeof SeaTurtle>'. Did you mean to write 'uuid'? ts(2322)
guid: '821',
};
// should be invalid
// @ts-expect-error - Property 'uuid' is missing in type '{}' but required in type 'Required<Pick<SeaTurtle, "uuid">>'.ts(2741)
const uniqueKeysOptionalStill = {};
});
});
//# sourceMappingURL=DomainPrimaryKeyShape.test.js.map