Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/clis/binance/commands.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import fs from 'node:fs';
import yaml from 'js-yaml';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { executePipeline } from '../../pipeline.js';
import { executePipeline } from '../../pipeline/index.js';

type BinanceRow = Record<string, unknown>;

function loadPipeline(name: string): any[] {
const file = new URL(`./${name}.yaml`, import.meta.url);
Expand All @@ -11,6 +13,9 @@ function loadPipeline(name: string): any[] {

function mockJsonOnce(payload: unknown) {
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({
ok: true,
status: 200,
statusText: 'OK',
json: vi.fn().mockResolvedValue(payload),
}));
}
Expand All @@ -28,7 +33,7 @@ describe('binance YAML adapters', () => {
{ symbol: 'MID', lastPrice: '3', priceChangePercent: '3.4', highPrice: '3', lowPrice: '3', quoteVolume: '11.0' },
]);

const result = await executePipeline(null, loadPipeline('top'), { args: { limit: 3 } });
const result = await executePipeline(null, loadPipeline('top'), { args: { limit: 3 } }) as BinanceRow[];

expect(result.map((item: any) => item.symbol)).toEqual(['LARGE', 'MID', 'SMALL']);
expect(result.map((item: any) => item.rank)).toEqual([1, 2, 3]);
Expand All @@ -41,7 +46,7 @@ describe('binance YAML adapters', () => {
{ symbol: 'HUNDRED', lastPrice: '1', priceChangePercent: '100.0', quoteVolume: '100' },
]);

const result = await executePipeline(null, loadPipeline('gainers'), { args: { limit: 3 } });
const result = await executePipeline(null, loadPipeline('gainers'), { args: { limit: 3 } }) as BinanceRow[];

expect(result.map((item: any) => item.symbol)).toEqual(['HUNDRED', 'TEN', 'NINE']);
});
Expand All @@ -54,7 +59,7 @@ describe('binance YAML adapters', () => {
],
});

const result = await executePipeline(null, loadPipeline('pairs'), { args: { limit: 10 } });
const result = await executePipeline(null, loadPipeline('pairs'), { args: { limit: 10 } }) as BinanceRow[];

expect(result).toEqual([
{ symbol: 'BTCUSDT', base: 'BTC', quote: 'USDT', status: 'TRADING' },
Expand Down