import { describe, it, expect, afterEach } from 'vitest';
import { cleanup, render } from 'vitest-browser-svelte';
import TimelineYAxis from './TimelineYAxis.svelte';

afterEach(cleanup);

describe('TimelineYAxis', () => {
	it('renders the maxCount and 0 labels', async () => {
		render(TimelineYAxis, { props: { maxCount: 42, barAreaHeight: 100 } });

		const axis = document.querySelector('[data-testid="timeline-y-axis"]') as HTMLElement;
		expect(axis.textContent).toContain('42');
		expect(axis.textContent).toContain('0');
	});

	it('applies the supplied barAreaHeight as inline style', async () => {
		render(TimelineYAxis, { props: { maxCount: 10, barAreaHeight: 250 } });

		const axis = document.querySelector('[data-testid="timeline-y-axis"]') as HTMLElement;
		expect(axis.style.height).toBe('250px');
	});

	it('renders zero count without crashing', async () => {
		render(TimelineYAxis, { props: { maxCount: 0, barAreaHeight: 100 } });

		const axis = document.querySelector('[data-testid="timeline-y-axis"]') as HTMLElement;
		expect(axis).not.toBeNull();
	});
});
