-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetupTests.js
More file actions
110 lines (100 loc) · 2.67 KB
/
setupTests.js
File metadata and controls
110 lines (100 loc) · 2.67 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// setupTests.js
import '@testing-library/jest-dom';
import { vi } from 'vitest';
// This will be set up before all tests run
// It sets up global mocks that don't rely on React's internals
// Mock timers
vi.useFakeTimers();
// Mock the useToast hook
vi.mock('@/hooks/use-toast', () => ({
useToast: () => ({
toast: vi.fn(),
dismiss: vi.fn(),
toasts: []
})
}));
// Mock UI components
vi.mock('@/components/ui/button', () => ({
Button: ({ children, onClick, disabled }) => (
<button onClick={onClick} disabled={disabled} data-testid="mock-button">
{children}
</button>
)
}));
vi.mock('@/components/ui/card', () => ({
Card: ({ children, className }) => (
<div data-testid="mock-card" className={className}>
{children}
</div>
),
CardHeader: ({ children, className }) => (
<div data-testid="mock-card-header" className={className}>
{children}
</div>
),
CardTitle: ({ children, className }) => (
<div data-testid="mock-card-title" className={className}>
{children}
</div>
),
CardContent: ({ children, className }) => (
<div data-testid="mock-card-content" className={className}>
{children}
</div>
)
}));
vi.mock('@/components/ui/progress', () => ({
Progress: ({ value, className }) => (
<div
data-testid="mock-progress"
className={className}
role="progressbar"
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={value}
>
{value}%
</div>
)
}));
vi.mock('@/components/ui/badge', () => ({
Badge: ({ children, variant, className }) => (
<span
data-testid="mock-badge"
className={className}
data-variant={variant}
>
{children}
</span>
)
}));
vi.mock('@/components/ui/alert', () => ({
Alert: ({ children, variant, className }) => (
<div
data-testid="mock-alert"
className={className}
data-variant={variant}
role="alert"
>
{children}
</div>
),
AlertDescription: ({ children, className }) => (
<div data-testid="mock-alert-description" className={className}>
{children}
</div>
)
}));
// Mock Lucide icons
vi.mock('lucide-react', () => ({
Play: () => <span data-testid="mock-icon-play">Play</span>,
Pause: () => <span data-testid="mock-icon-pause">Pause</span>,
Square: () => <span data-testid="mock-icon-square">Square</span>,
AlertCircle: () => <span data-testid="mock-icon-alert-circle">AlertCircle</span>,
Clock: () => <span data-testid="mock-icon-clock">Clock</span>,
Timer: () => <span data-testid="mock-icon-timer">Timer</span>
}));
// Mock utility functions
vi.mock('@/lib/utils', () => ({
cn: (...args) => args.filter(Boolean).join(' ')
}));