30 lines
963 B
TypeScript
30 lines
963 B
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
|
|
import type { RequestClient } from '@/utils/request';
|
|
import { createMarketOverviewApi } from './index';
|
|
|
|
describe('市场概览业务 API', () => {
|
|
it('使用独立版本化路径请求五个模块', async () => {
|
|
const requestMock = vi.fn((config: Parameters<RequestClient>[0]) => {
|
|
void config;
|
|
return Promise.resolve({});
|
|
});
|
|
const requestClient = requestMock as unknown as RequestClient;
|
|
const api = createMarketOverviewApi(requestClient);
|
|
|
|
await api.getSummary();
|
|
await api.getIndices();
|
|
await api.getBreadth();
|
|
await api.getSectors();
|
|
await api.getFunds();
|
|
|
|
expect(requestMock.mock.calls.map(([config]) => config.url)).toEqual([
|
|
'/api/v1/market-overview/summary',
|
|
'/api/v1/market-overview/indices',
|
|
'/api/v1/market-overview/breadth',
|
|
'/api/v1/market-overview/sectors',
|
|
'/api/v1/market-overview/funds',
|
|
]);
|
|
});
|
|
});
|