Spaces:
Running
Running
Download source/teaql-ts/tests/runtime-module.test.ts from teaql/browser-sqlite-playground: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/spaces/teaql/browser-sqlite-playground/resolve/main/source/teaql-ts/tests/runtime-module.test.ts
- Command line
-
hf download hf://spaces/teaql/browser-sqlite-playground/source/teaql-ts/tests/runtime-module.test.ts
-
curl -L -o runtime-module.test.ts https://huggingface.co/spaces/teaql/browser-sqlite-playground/resolve/main/source/teaql-ts/tests/runtime-module.test.ts
1.42 kB
| 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'); | |
| }); | |
| }); | |