|
1 | 1 | import { render, screen } from '@testing-library/react';
|
2 | 2 | import '@testing-library/jest-dom';
|
| 3 | +import { vi, describe, test, expect, beforeEach } from 'vitest'; |
3 | 4 | import { Timeline } from '../Timeline';
|
4 | 5 | import { TimelineEntry } from '../types';
|
5 | 6 |
|
6 | 7 | // Mock the TimelineStep component
|
7 |
| -jest.mock('../components/TimelineStep', () => { |
8 |
| - return { |
9 |
| - __esModule: true, |
10 |
| - default: ({ entry, index, isSelected, onSelect }: any) => ( |
11 |
| - <div |
12 |
| - data-testid={`timeline-step-${index}`} |
13 |
| - data-selected={isSelected} |
14 |
| - onClick={() => onSelect(index)} |
15 |
| - > |
16 |
| - <span>{entry.type}</span> |
17 |
| - {entry.content && <span>{entry.content}</span>} |
18 |
| - {entry.command && <span>{entry.command}</span>} |
19 |
| - </div> |
20 |
| - ) |
21 |
| - }; |
22 |
| -}); |
| 8 | +vi.mock('../components/TimelineStep', () => ({ |
| 9 | + default: ({ entry, index, isSelected, onSelect }: any) => ( |
| 10 | + <div |
| 11 | + data-testid={`timeline-step-${index}`} |
| 12 | + data-selected={isSelected.toString()} |
| 13 | + onClick={() => onSelect(index)} |
| 14 | + > |
| 15 | + <span>{entry.type}</span> |
| 16 | + {entry.content && <span>{entry.content}</span>} |
| 17 | + {entry.command && <span>{entry.command}</span>} |
| 18 | + </div> |
| 19 | + ) |
| 20 | +})); |
23 | 21 |
|
24 | 22 | describe('Timeline Component', () => {
|
25 |
| - const mockOnStepSelect = jest.fn(); |
26 |
| - const mockOnCommandClick = jest.fn(); |
27 |
| - const mockFormatTimelineDate = jest.fn().mockReturnValue('12:34 PM'); |
| 23 | + const mockOnStepSelect = vi.fn(); |
| 24 | + const mockOnCommandClick = vi.fn(); |
| 25 | + const mockFormatTimelineDate = vi.fn().mockReturnValue('12:34 PM'); |
28 | 26 |
|
29 | 27 | // Basic test to ensure the component renders
|
30 | 28 | test('renders without crashing', () => {
|
|
0 commit comments