feat(frontend): 结果页组件—MetricCards指标卡+5图(基准/Alpha/Beta/波动率/回撤)+API封装

This commit is contained in:
2026-07-11 13:54:05 +08:00
parent 304844903c
commit d0315ccbdf
13 changed files with 683 additions and 0 deletions
@@ -0,0 +1,40 @@
import { describe, expect, it, vi, beforeEach } from 'vitest'
import { mount } from '@vue/test-utils'
import BenchmarkCurve from './BenchmarkCurve.vue'
// Mock echarts to avoid canvas issues in jsdom
vi.mock('echarts', () => ({
init: vi.fn(() => ({
setOption: vi.fn(),
dispose: vi.fn(),
resize: vi.fn(),
})),
}))
describe('BenchmarkCurve.vue', () => {
beforeEach(() => {
vi.clearAllMocks()
})
it('renders chart container without crashing', () => {
const props = {
dates: ['2024-01-01', '2024-01-02', '2024-01-03'],
strategy: [1.0, 1.02, 1.05],
benchmark: [1.0, 1.01, 1.03],
}
const wrapper = mount(BenchmarkCurve, { props })
expect(wrapper.find('.chart-box').exists()).toBe(true)
})
it('passes props correctly', () => {
const props = {
dates: ['2024-01-01', '2024-01-02'],
strategy: [1.0, 1.02],
benchmark: [1.0, 1.01],
}
const wrapper = mount(BenchmarkCurve, { props })
expect(wrapper.props()).toEqual(props)
})
})