Spaces:
Running
Running
File size: 1,418 Bytes
aa89cb5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import { RuntimeModule } from '../src/core/runtime-module';
describe('RuntimeModule', () => {
test('is a passive composable metadata manifest', () => {
const first = new RuntimeModule({ A: { table: 'a', columns: {} } }, {}, {
defaultDomainRoot: { entity: 'A', id: '1' },
constants: [{ entity: 'AState', id: '1001', values: { name: 'First' } }],
});
const second = new RuntimeModule({ B: { table: 'b', columns: {} } }, {}, {
constants: [
{ entity: 'AState', id: '1001', values: { name: 'Reconciled' } },
{ entity: 'BState', id: '2001' },
],
});
const combined = first.and(second);
expect(Object.keys(combined.schemas)).toEqual(['A', 'B']);
expect(Object.isFrozen(combined.schemas)).toBe(true);
expect(combined.bootstrap.defaultDomainRoot).toEqual({ entity: 'A', id: '1' });
expect(combined.bootstrap.constants).toEqual([
{ entity: 'AState', id: '1001', values: { name: 'Reconciled' } },
{ entity: 'BState', id: '2001' },
]);
});
test('rejects composition with different Default Domain Roots', () => {
const first = new RuntimeModule({}, {}, {
defaultDomainRoot: { entity: 'Platform', id: '1' },
});
const second = new RuntimeModule({}, {}, {
defaultDomainRoot: { entity: 'Organization', id: '1' },
});
expect(() => first.and(second)).toThrow('different Default Domain Roots');
});
});
|