39 lines
954 B
TypeScript
39 lines
954 B
TypeScript
import { describe, expect, it, vi, beforeEach } from 'vitest'
|
|
import { mount } from '@vue/test-utils'
|
|
import DrawdownChart from './DrawdownChart.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('DrawdownChart.vue', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
it('renders chart container without crashing', () => {
|
|
const props = {
|
|
dates: ['2024-01-01', '2024-01-02', '2024-01-03'],
|
|
drawdown: [0.0, -0.02, -0.08],
|
|
}
|
|
|
|
const wrapper = mount(DrawdownChart, { props })
|
|
expect(wrapper.find('.chart-box').exists()).toBe(true)
|
|
})
|
|
|
|
it('passes props correctly', () => {
|
|
const props = {
|
|
dates: ['2024-01-01', '2024-01-02'],
|
|
drawdown: [0.0, -0.02],
|
|
}
|
|
|
|
const wrapper = mount(DrawdownChart, { props })
|
|
expect(wrapper.props()).toEqual(props)
|
|
})
|
|
})
|