forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStepIndicator.test.tsx
More file actions
39 lines (34 loc) · 1.5 KB
/
Copy pathStepIndicator.test.tsx
File metadata and controls
39 lines (34 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { render, screen } from '@testing-library/react';
import { describe, it, expect } from 'vitest';
import { StepIndicator } from './StepIndicator';
const STEPS = [
{ label: 'Basic Info' },
{ label: 'Method' },
{ label: 'Participants' },
{ label: 'Review' },
];
describe('StepIndicator', () => {
it('renders the correct number of steps', () => {
render(<StepIndicator steps={STEPS} currentStep={0} />);
const labels = screen.getAllByText(/Basic Info|Method|Participants|Review/);
expect(labels.length).toBe(4);
});
it('shows step numbers for incomplete steps', () => {
render(<StepIndicator steps={STEPS} currentStep={0} />);
expect(screen.getByText('2')).toBeDefined();
expect(screen.getByText('3')).toBeDefined();
expect(screen.getByText('4')).toBeDefined();
});
it('highlights the active step label', () => {
const { container } = render(<StepIndicator steps={STEPS} currentStep={1} />);
const methodLabel = screen.getByText('Method');
expect(methodLabel.className).toContain('text-purple-600');
expect(container).toBeTruthy();
});
it('renders a check for completed steps', () => {
const { container } = render(<StepIndicator steps={STEPS} currentStep={2} />);
// Steps 0 and 1 should have check icons (svg), not numbers
const stepNumbers = container.querySelectorAll('div[class*="rounded-full"]');
expect(stepNumbers.length).toBeGreaterThan(0);
});
});