domain-objects
Version:
A simple, convenient way to represent domain objects, leverage domain knowledge, and add runtime validation in your code base.
42 lines • 1.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const DomainEntity_1 = require("../instantiation/DomainEntity");
const DomainObject_1 = require("../instantiation/DomainObject");
const getMetadataKeys_1 = require("./getMetadataKeys");
describe('getMetadataKeys', () => {
it('should return the defaults, if not explicitly defined', () => {
class Mineral extends DomainObject_1.DomainObject {
}
const mineral = new Mineral({ name: 'magnesium' });
const metadataKeys = (0, getMetadataKeys_1.getMetadataKeys)(mineral);
expect(metadataKeys).toEqual([
'id',
'uuid',
'createdAt',
'updatedAt',
'effectiveAt',
]);
});
it('should return the explicitly defined metadata keys, if defined', () => {
class Mineral extends DomainObject_1.DomainObject {
}
Mineral.metadata = ['id', 'uuid'];
const mineral = new Mineral({ name: 'magnesium' });
const metadataKeys = (0, getMetadataKeys_1.getMetadataKeys)(mineral);
expect(metadataKeys).toEqual(['id', 'uuid']);
});
it('should not include uuid in the default metadata keys of a DomainEntity which specified uuid as part of its unique key', () => {
class Mineral extends DomainEntity_1.DomainEntity {
}
Mineral.unique = ['uuid'];
const mineral = new Mineral({ uuid: '__UUID__', name: 'magnesium' });
const metadataKeys = (0, getMetadataKeys_1.getMetadataKeys)(mineral);
expect(metadataKeys).toEqual([
'id',
'createdAt',
'updatedAt',
'effectiveAt',
]);
});
});
//# sourceMappingURL=getMetadataKeys.test.js.map