import { vi } from 'vitest'; /** * Test double for Chart.js's `Chart` class, shared by `chart-canvas.spec.ts` and * `overview.spec.ts`. jsdom has no canvas 2D context, so real Chart.js cannot render * in this project's test environment — specs mock the whole `chart.js` module via * `vi.mock('chart.js', () => ({ Chart: MockChart, registerables: [] }))` and assert * on the Chart.js lifecycle contract (constructor args, update(), destroy()) instead. * * Not a `*.spec.ts` file on purpose: it exports a class rather than defining tests, * so it must not be picked up by the test runner's `**\/*.spec.ts` include glob. */ export class MockChart { static register = vi.fn(); static instances: MockChart[] = []; data: unknown; options: unknown; config: { type: unknown; data: unknown; options: unknown }; destroy = vi.fn(); update = vi.fn(); constructor( public ctx: unknown, config: { type: unknown; data: unknown; options: unknown }, ) { this.config = config; this.data = config.data; this.options = config.options; MockChart.instances.push(this); } }