Files
sanguo_vnpy_v2/frontend/src/components/backtest/BenchmarkCurve.spec.ts
T

41 lines
1022 B
TypeScript

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)
})
})