stock-bot/scripts/test/orchestrator-container.test.ts

22 lines
1.3 KiB
TypeScript

import { expect, test } from 'bun:test';
import { createExampleRuntime } from '../../apps/stock/orchestrator/examples/example-runtime';
import { backtestDatasetLimitsSchema } from '../../apps/stock/config/src/schemas/stock-app.schema';
test('offline examples use the shared DI graph without starting a real-time feed', async () => {
const runtime = await createExampleRuntime();
expect(runtime.container.custom?.StorageService).toBe(runtime.storageService);
expect(runtime.container.custom?.StrategyManager).toBe(runtime.strategyManager);
expect(runtime.container.mongodb).toBeNull();
expect(runtime.container.queueManager).toBeNull();
expect(runtime.modeManager.getConfig()).toBeNull();
expect(() => runtime.modeManager.getTradingEngine()).toThrow('Trading engine not initialized');
});
test('dataset configuration accepts partial budgets and rejects invalid or misspelled ceilings', () => {
expect(backtestDatasetLimitsSchema.parse({ maxBars: 1000 })).toEqual({ maxBars: 1000 });
expect(backtestDatasetLimitsSchema.parse({})).toEqual({});
for (const maxBars of [0, -1, 1.5, Infinity, Number.MAX_SAFE_INTEGER]) {
expect(backtestDatasetLimitsSchema.safeParse({ maxBars }).success).toBe(false);
}
expect(backtestDatasetLimitsSchema.safeParse({ maxBar: 1000 }).success).toBe(false);
});