feat(FEAT-MO-001): 接入TDX市场宽度板块与成交额趋势
This commit is contained in:
@@ -72,13 +72,32 @@ describe('市场概览 HTTP API', () => {
|
||||
expect(JSON.stringify(response.body)).not.toContain('127.0.0.1');
|
||||
});
|
||||
|
||||
it('未提供的板块能力返回可读的不可用状态', async () => {
|
||||
it('板块接口返回可点击的 TDX 一级行业对象', async () => {
|
||||
const client = {
|
||||
request: vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce({
|
||||
ErrorId: '0',
|
||||
Value: [{ Code: '881319.SH', Name: '半导体' }],
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
ErrorId: '0',
|
||||
Value: {
|
||||
'881319.SH': {
|
||||
Date: ['20260817', '20260818'],
|
||||
Open: ['100', '101'],
|
||||
High: ['102', '103'],
|
||||
Low: ['99', '100'],
|
||||
Close: ['100', '102'],
|
||||
Amount: ['1000', '1200'],
|
||||
Volume: ['100', '120'],
|
||||
},
|
||||
},
|
||||
}),
|
||||
};
|
||||
const moduleRef = await Test.createTestingModule({
|
||||
controllers: [MarketOverviewController],
|
||||
providers: [
|
||||
MarketOverviewService,
|
||||
{ provide: TDX_CLIENT_PORT, useValue: { request: vi.fn() } },
|
||||
],
|
||||
providers: [MarketOverviewService, { provide: TDX_CLIENT_PORT, useValue: client }],
|
||||
}).compile();
|
||||
app = moduleRef.createNestApplication();
|
||||
app.setGlobalPrefix('api/v1');
|
||||
@@ -88,7 +107,13 @@ describe('市场概览 HTTP API', () => {
|
||||
.get('/api/v1/market-overview/sectors')
|
||||
.expect(200);
|
||||
|
||||
expect(response.body).toMatchObject({ source: 'tdx', status: 'unavailable', data: null });
|
||||
expect(response.body.warnings[0]).toContain('板块排行');
|
||||
expect(response.body).toMatchObject({
|
||||
source: 'tdx',
|
||||
status: 'fresh',
|
||||
data: {
|
||||
items: [expect.objectContaining({ code: '881319.SH', name: '半导体', changePercent: 2 })],
|
||||
},
|
||||
});
|
||||
expect(JSON.stringify(response.body)).not.toContain('127.0.0.1');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user