import { describe, it, expect } from 'vitest';
import { render } from '@testing-library/svelte';
import StepperCompact from './StepperCompact.svelte';
describe('StepperCompact component', () => {
    it('renders with a label by default', () => {
        const { container } = render(StepperCompact, { props: { label: 'My label' } });
        expect(container.querySelector('.mc-stepper-compact')).toBeTruthy();
        expect(container.querySelector('.mc-stepper-compact__label')?.textContent).toBe('My label');
        expect(container.querySelector('.mc-stepper-compact__description')).toBeFalsy();
    });
    it('calculates progress value correctly', () => {
        const { container } = render(StepperCompact, {
            props: {
                label: 'Étape 2',
                value: 2,
                maxsteps: 5,
            },
        });
        expect(container.querySelector('.mc-stepper-compact__progress')).toBeTruthy();
    });
    it('displays current step and max steps in progress bar', () => {
        const { container } = render(StepperCompact, {
            props: {
                label: 'Step 3',
                value: 3,
                maxsteps: 7,
            },
        });
        expect(container.querySelector('.mc-stepper-compact__progress')).toBeTruthy();
    });
    it('renders with custom size', () => {
        const { container } = render(StepperCompact, {
            props: {
                label: 'Taille m',
                size: 'm',
            },
        });
        expect(container.querySelector('.mc-stepper-compact__progress')).toBeTruthy();
    });
    it('handles edge cases for progress calculation with value 0', () => {
        const { container } = render(StepperCompact, {
            props: {
                label: 'Zero',
                value: 0,
                maxsteps: 1,
            },
        });
        expect(container.querySelector('.mc-stepper-compact__progress')).toBeTruthy();
    });
    it('handles maximum progress correctly', () => {
        const { container } = render(StepperCompact, {
            props: {
                label: 'Maximum',
                value: 5,
                maxsteps: 5,
            },
        });
        expect(container.querySelector('.mc-stepper-compact__progress')).toBeTruthy();
    });
    it('shows description when additionalInfo is true and description is provided', () => {
        const { container } = render(StepperCompact, {
            props: {
                label: 'Test step',
                description: 'Description visible',
                additionalInfo: true,
            },
        });
        expect(container.querySelector('.mc-stepper-compact__description')?.textContent).toBe('Description visible');
    });
    it('hides description when additionalInfo is true and description is empty', () => {
        const { container } = render(StepperCompact, {
            props: {
                label: 'Test step',
                description: '',
                additionalInfo: true,
            },
        });
        expect(container.querySelector('.mc-stepper-compact__description')).toBeFalsy();
    });
    it('renders with custom label', () => {
        const customLabel = 'Step 2 of 5';
        const { container } = render(StepperCompact, {
            props: {
                label: customLabel,
            },
        });
        expect(container.querySelector('.mc-stepper-compact__label')?.textContent).toBe(customLabel);
    });
    it('handles null/undefined values gracefully', () => {
        const { container } = render(StepperCompact, {
            props: {
                label: 'Undefined steps',
                value: undefined,
                maxsteps: undefined,
            },
        });
        expect(container.querySelector('.mc-stepper-compact__progress')).toBeTruthy();
    });
    it('has proper ARIA label on progress bar', () => {
        const { container } = render(StepperCompact, {
            props: {
                label: 'ARIA',
            },
        });
        expect(container.querySelector('.mc-stepper-compact__progress')).toBeTruthy();
    });
    it('applies correct CSS classes', () => {
        const { container } = render(StepperCompact, {
            props: {
                label: 'Classes',
            },
        });
        expect(container.querySelector('.mc-stepper-compact')).toBeTruthy();
        expect(container.querySelector('.mc-circular-progressbar')).toBeTruthy();
        expect(container.querySelector('.mc-stepper-compact__progress')).toBeTruthy();
        expect(container.querySelector('.mc-stepper-compact__label-container')).toBeTruthy();
        expect(container.querySelector('.mc-stepper-compact__label')).toBeTruthy();
    });
});
