@moontra/moonui-pro 2.20.1 → 2.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +691 -261
- package/dist/index.mjs +7418 -4934
- package/package.json +11 -5
- package/plugin/index.d.ts +86 -0
- package/plugin/index.js +308 -0
- package/scripts/postbuild.js +27 -0
- package/scripts/postinstall.js +176 -23
- package/src/__tests__/use-intersection-observer.test.tsx +0 -216
- package/src/__tests__/use-local-storage.test.tsx +0 -174
- package/src/__tests__/use-pro-access.test.tsx +0 -183
- package/src/components/advanced-chart/advanced-chart.test.tsx +0 -281
- package/src/components/advanced-chart/index.tsx +0 -1242
- package/src/components/advanced-forms/index.tsx +0 -426
- package/src/components/animated-button/index.tsx +0 -385
- package/src/components/calendar/event-dialog.tsx +0 -372
- package/src/components/calendar/index.tsx +0 -1073
- package/src/components/calendar-pro/index.tsx +0 -1697
- package/src/components/color-picker/index.tsx +0 -432
- package/src/components/credit-card-input/index.tsx +0 -406
- package/src/components/dashboard/dashboard-grid.tsx +0 -462
- package/src/components/dashboard/demo.tsx +0 -425
- package/src/components/dashboard/index.tsx +0 -1046
- package/src/components/dashboard/time-range-picker.tsx +0 -336
- package/src/components/dashboard/types.ts +0 -222
- package/src/components/dashboard/widgets/activity-feed.tsx +0 -344
- package/src/components/dashboard/widgets/chart-widget.tsx +0 -418
- package/src/components/dashboard/widgets/metric-card.tsx +0 -343
- package/src/components/data-table/data-table-bulk-actions.tsx +0 -204
- package/src/components/data-table/data-table-column-toggle.tsx +0 -169
- package/src/components/data-table/data-table-export.ts +0 -156
- package/src/components/data-table/data-table-filter-drawer.tsx +0 -448
- package/src/components/data-table/data-table.test.tsx +0 -187
- package/src/components/data-table/index.tsx +0 -845
- package/src/components/draggable-list/index.tsx +0 -100
- package/src/components/enhanced/badge.tsx +0 -191
- package/src/components/enhanced/button.tsx +0 -362
- package/src/components/enhanced/card.tsx +0 -266
- package/src/components/enhanced/dialog.tsx +0 -246
- package/src/components/enhanced/index.ts +0 -4
- package/src/components/error-boundary/index.tsx +0 -109
- package/src/components/file-upload/file-upload.test.tsx +0 -243
- package/src/components/file-upload/index.tsx +0 -1660
- package/src/components/floating-action-button/index.tsx +0 -206
- package/src/components/form-wizard/form-wizard-context.tsx +0 -307
- package/src/components/form-wizard/form-wizard-navigation.tsx +0 -118
- package/src/components/form-wizard/form-wizard-progress.tsx +0 -298
- package/src/components/form-wizard/form-wizard-step.tsx +0 -111
- package/src/components/form-wizard/index.tsx +0 -102
- package/src/components/form-wizard/types.ts +0 -76
- package/src/components/gesture-drawer/index.tsx +0 -551
- package/src/components/github-stars/github-api.ts +0 -426
- package/src/components/github-stars/hooks.ts +0 -516
- package/src/components/github-stars/index.tsx +0 -375
- package/src/components/github-stars/types.ts +0 -148
- package/src/components/github-stars/variants.tsx +0 -513
- package/src/components/health-check/index.tsx +0 -439
- package/src/components/hover-card-3d/index.tsx +0 -530
- package/src/components/index.ts +0 -128
- package/src/components/internal/index.ts +0 -78
- package/src/components/kanban/add-card-modal.tsx +0 -502
- package/src/components/kanban/card-detail-modal.tsx +0 -761
- package/src/components/kanban/index.ts +0 -13
- package/src/components/kanban/kanban.tsx +0 -1684
- package/src/components/kanban/types.ts +0 -168
- package/src/components/lazy-component/index.tsx +0 -823
- package/src/components/license-error/index.tsx +0 -29
- package/src/components/magnetic-button/index.tsx +0 -167
- package/src/components/memory-efficient-data/index.tsx +0 -1016
- package/src/components/moonui-quiz-form/index.tsx +0 -817
- package/src/components/optimized-image/index.tsx +0 -425
- package/src/components/performance-debugger/index.tsx +0 -589
- package/src/components/performance-monitor/index.tsx +0 -794
- package/src/components/phone-number-input/index.tsx +0 -338
- package/src/components/pinch-zoom/index.tsx +0 -566
- package/src/components/quiz-form/index.tsx +0 -479
- package/src/components/rich-text-editor/index-old-backup.tsx +0 -437
- package/src/components/rich-text-editor/index.tsx +0 -2324
- package/src/components/rich-text-editor/slash-commands-extension.ts +0 -220
- package/src/components/rich-text-editor/slash-commands.css +0 -35
- package/src/components/rich-text-editor/table-styles.css +0 -65
- package/src/components/sidebar/index.tsx +0 -865
- package/src/components/spotlight-card/index.tsx +0 -191
- package/src/components/swipeable-card/index.tsx +0 -100
- package/src/components/timeline/index.tsx +0 -1148
- package/src/components/ui/accordion.tsx +0 -73
- package/src/components/ui/alert-dialog.tsx +0 -141
- package/src/components/ui/alert.tsx +0 -141
- package/src/components/ui/aspect-ratio.tsx +0 -245
- package/src/components/ui/avatar.tsx +0 -153
- package/src/components/ui/badge.tsx +0 -228
- package/src/components/ui/breadcrumb.tsx +0 -214
- package/src/components/ui/button.tsx +0 -222
- package/src/components/ui/calendar.tsx +0 -387
- package/src/components/ui/card.tsx +0 -214
- package/src/components/ui/checkbox.tsx +0 -259
- package/src/components/ui/collapsible.tsx +0 -135
- package/src/components/ui/color-picker.tsx +0 -97
- package/src/components/ui/command.tsx +0 -225
- package/src/components/ui/dialog.tsx +0 -334
- package/src/components/ui/dropdown-menu.tsx +0 -218
- package/src/components/ui/gesture-drawer.tsx +0 -11
- package/src/components/ui/hover-card.tsx +0 -29
- package/src/components/ui/index.ts +0 -190
- package/src/components/ui/input.tsx +0 -222
- package/src/components/ui/label.tsx +0 -29
- package/src/components/ui/lightbox.tsx +0 -606
- package/src/components/ui/magnetic-button.tsx +0 -129
- package/src/components/ui/media-gallery.tsx +0 -612
- package/src/components/ui/pagination.tsx +0 -123
- package/src/components/ui/popover.tsx +0 -185
- package/src/components/ui/progress.tsx +0 -30
- package/src/components/ui/radio-group.tsx +0 -257
- package/src/components/ui/scroll-area.tsx +0 -47
- package/src/components/ui/select.tsx +0 -374
- package/src/components/ui/separator.tsx +0 -145
- package/src/components/ui/sheet.tsx +0 -139
- package/src/components/ui/skeleton.tsx +0 -20
- package/src/components/ui/slider.tsx +0 -354
- package/src/components/ui/spotlight-card.tsx +0 -119
- package/src/components/ui/switch.tsx +0 -86
- package/src/components/ui/table.tsx +0 -329
- package/src/components/ui/tabs.tsx +0 -198
- package/src/components/ui/textarea.tsx +0 -28
- package/src/components/ui/toast.tsx +0 -317
- package/src/components/ui/toggle.tsx +0 -119
- package/src/components/ui/tooltip.tsx +0 -151
- package/src/components/virtual-list/index.tsx +0 -668
- package/src/hooks/use-chart.ts +0 -205
- package/src/hooks/use-data-table.ts +0 -182
- package/src/hooks/use-docs-pro-access.ts +0 -13
- package/src/hooks/use-license-check.ts +0 -65
- package/src/hooks/use-subscription.ts +0 -19
- package/src/hooks/use-toast.ts +0 -15
- package/src/index.ts +0 -14
- package/src/lib/ai-providers.ts +0 -377
- package/src/lib/component-metadata.ts +0 -18
- package/src/lib/micro-interactions.ts +0 -255
- package/src/lib/paddle.ts +0 -17
- package/src/lib/utils.ts +0 -6
- package/src/patterns/login-form/index.tsx +0 -276
- package/src/patterns/login-form/types.ts +0 -67
- package/src/setupTests.ts +0 -41
- package/src/styles/advanced-chart.css +0 -239
- package/src/styles/calendar.css +0 -35
- package/src/styles/design-system.css +0 -363
- package/src/styles/index.css +0 -85
- package/src/styles/tailwind.css +0 -7
- package/src/styles/tokens.css +0 -455
- package/src/types/moonui.d.ts +0 -22
- package/src/types/next-auth.d.ts +0 -21
- package/src/use-intersection-observer.tsx +0 -154
- package/src/use-local-storage.tsx +0 -71
- package/src/use-paddle.ts +0 -138
- package/src/use-performance-optimizer.ts +0 -389
- package/src/use-pro-access.ts +0 -141
- package/src/use-scroll-animation.ts +0 -219
- package/src/use-subscription.ts +0 -37
- package/src/use-toast.ts +0 -32
- package/src/utils/chart-helpers.ts +0 -357
- package/src/utils/cn.ts +0 -6
- package/src/utils/data-processing.ts +0 -151
- package/src/utils/license-validator.tsx +0 -183
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { renderHook } from '@testing-library/react'
|
|
2
|
-
import { useSession } from 'next-auth/react'
|
|
3
|
-
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
4
|
-
import { useProAccess } from '../use-pro-access'
|
|
5
|
-
import React from 'react'
|
|
6
|
-
|
|
7
|
-
// Mock next-auth
|
|
8
|
-
jest.mock('next-auth/react')
|
|
9
|
-
const mockUseSession = useSession as jest.MockedFunction<typeof useSession>
|
|
10
|
-
|
|
11
|
-
// Mock fetch
|
|
12
|
-
global.fetch = jest.fn()
|
|
13
|
-
|
|
14
|
-
// Test wrapper with QueryClient
|
|
15
|
-
const createWrapper = () => {
|
|
16
|
-
const queryClient = new QueryClient({
|
|
17
|
-
defaultOptions: {
|
|
18
|
-
queries: {
|
|
19
|
-
retry: false,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
})
|
|
23
|
-
const TestWrapper = ({ children }: { children: React.ReactNode }) => (
|
|
24
|
-
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
|
25
|
-
)
|
|
26
|
-
TestWrapper.displayName = 'TestWrapper'
|
|
27
|
-
return TestWrapper
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
describe('useProAccess Hook', () => {
|
|
31
|
-
beforeEach(() => {
|
|
32
|
-
jest.clearAllMocks()
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('returns false for unauthenticated users', () => {
|
|
36
|
-
mockUseSession.mockReturnValue({
|
|
37
|
-
data: null,
|
|
38
|
-
status: 'unauthenticated',
|
|
39
|
-
update: jest.fn(),
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
const { result } = renderHook(() => useProAccess(), {
|
|
43
|
-
wrapper: createWrapper()
|
|
44
|
-
})
|
|
45
|
-
expect(result.current.hasProAccess).toBe(false)
|
|
46
|
-
expect(result.current.isLoading).toBe(false)
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('returns false for authenticated users without pro subscription', () => {
|
|
50
|
-
mockUseSession.mockReturnValue({
|
|
51
|
-
data: {
|
|
52
|
-
user: {
|
|
53
|
-
id: '1',
|
|
54
|
-
email: 'user@example.com',
|
|
55
|
-
name: 'Test User',
|
|
56
|
-
},
|
|
57
|
-
expires: '2024-12-31',
|
|
58
|
-
},
|
|
59
|
-
status: 'authenticated',
|
|
60
|
-
update: jest.fn(),
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
const { result } = renderHook(() => useProAccess(), {
|
|
64
|
-
wrapper: createWrapper()
|
|
65
|
-
})
|
|
66
|
-
expect(result.current.hasProAccess).toBe(false)
|
|
67
|
-
expect(result.current.isLoading).toBe(false)
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('returns true for authenticated users with active pro subscription', () => {
|
|
71
|
-
mockUseSession.mockReturnValue({
|
|
72
|
-
data: {
|
|
73
|
-
user: {
|
|
74
|
-
id: '1',
|
|
75
|
-
email: 'pro@example.com',
|
|
76
|
-
name: 'Pro User',
|
|
77
|
-
subscription: {
|
|
78
|
-
plan: 'pro',
|
|
79
|
-
status: 'active',
|
|
80
|
-
expiresAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(), // 30 days from now
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
expires: '2024-12-31',
|
|
84
|
-
},
|
|
85
|
-
status: 'authenticated',
|
|
86
|
-
update: jest.fn(),
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
const { result } = renderHook(() => useProAccess(), {
|
|
90
|
-
wrapper: createWrapper()
|
|
91
|
-
})
|
|
92
|
-
expect(result.current.hasProAccess).toBe(true)
|
|
93
|
-
expect(result.current.isLoading).toBe(false)
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
it('returns false for users with expired pro subscription', () => {
|
|
97
|
-
mockUseSession.mockReturnValue({
|
|
98
|
-
data: {
|
|
99
|
-
user: {
|
|
100
|
-
id: '1',
|
|
101
|
-
email: 'expired@example.com',
|
|
102
|
-
name: 'Expired User',
|
|
103
|
-
subscription: {
|
|
104
|
-
plan: 'pro',
|
|
105
|
-
status: 'active',
|
|
106
|
-
expiresAt: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString(), // 1 day ago
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
expires: '2024-12-31',
|
|
110
|
-
},
|
|
111
|
-
status: 'authenticated',
|
|
112
|
-
update: jest.fn(),
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
const { result } = renderHook(() => useProAccess(), {
|
|
116
|
-
wrapper: createWrapper()
|
|
117
|
-
})
|
|
118
|
-
expect(result.current.hasProAccess).toBe(false)
|
|
119
|
-
expect(result.current.isLoading).toBe(false)
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
it('returns false for users with cancelled pro subscription', () => {
|
|
123
|
-
mockUseSession.mockReturnValue({
|
|
124
|
-
data: {
|
|
125
|
-
user: {
|
|
126
|
-
id: '1',
|
|
127
|
-
email: 'cancelled@example.com',
|
|
128
|
-
name: 'Cancelled User',
|
|
129
|
-
subscription: {
|
|
130
|
-
plan: 'pro',
|
|
131
|
-
status: 'cancelled',
|
|
132
|
-
expiresAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(),
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
expires: '2024-12-31',
|
|
136
|
-
},
|
|
137
|
-
status: 'authenticated',
|
|
138
|
-
update: jest.fn(),
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
const { result } = renderHook(() => useProAccess(), {
|
|
142
|
-
wrapper: createWrapper()
|
|
143
|
-
})
|
|
144
|
-
expect(result.current.hasProAccess).toBe(false)
|
|
145
|
-
expect(result.current.isLoading).toBe(false)
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
it('returns loading state when session is loading', () => {
|
|
149
|
-
mockUseSession.mockReturnValue({
|
|
150
|
-
data: null,
|
|
151
|
-
status: 'loading',
|
|
152
|
-
update: jest.fn(),
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
const { result } = renderHook(() => useProAccess(), {
|
|
156
|
-
wrapper: createWrapper()
|
|
157
|
-
})
|
|
158
|
-
expect(result.current.hasProAccess).toBe(false)
|
|
159
|
-
expect(result.current.isLoading).toBe(true)
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
it('handles edge cases with missing subscription data', () => {
|
|
163
|
-
mockUseSession.mockReturnValue({
|
|
164
|
-
data: {
|
|
165
|
-
user: {
|
|
166
|
-
id: '1',
|
|
167
|
-
email: 'user@example.com',
|
|
168
|
-
name: 'Test User',
|
|
169
|
-
subscription: undefined,
|
|
170
|
-
},
|
|
171
|
-
expires: '2024-12-31',
|
|
172
|
-
},
|
|
173
|
-
status: 'authenticated',
|
|
174
|
-
update: jest.fn(),
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
const { result } = renderHook(() => useProAccess(), {
|
|
178
|
-
wrapper: createWrapper()
|
|
179
|
-
})
|
|
180
|
-
expect(result.current.hasProAccess).toBe(false)
|
|
181
|
-
expect(result.current.isLoading).toBe(false)
|
|
182
|
-
})
|
|
183
|
-
})
|
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import { render, screen, fireEvent } from '@testing-library/react'
|
|
2
|
-
import '@testing-library/jest-dom'
|
|
3
|
-
import { AdvancedChart } from './index'
|
|
4
|
-
|
|
5
|
-
// Mock recharts to avoid canvas issues in tests
|
|
6
|
-
jest.mock('recharts', () => ({
|
|
7
|
-
ResponsiveContainer: ({ children }: any) => <div data-testid="responsive-container">{children}</div>,
|
|
8
|
-
LineChart: ({ children }: any) => <div data-testid="line-chart">{children}</div>,
|
|
9
|
-
BarChart: ({ children }: any) => <div data-testid="bar-chart">{children}</div>,
|
|
10
|
-
AreaChart: ({ children }: any) => <div data-testid="area-chart">{children}</div>,
|
|
11
|
-
PieChart: ({ children }: any) => <div data-testid="pie-chart">{children}</div>,
|
|
12
|
-
ScatterChart: ({ children }: any) => <div data-testid="scatter-chart">{children}</div>,
|
|
13
|
-
Line: () => <div data-testid="line" />,
|
|
14
|
-
Bar: () => <div data-testid="bar" />,
|
|
15
|
-
Area: () => <div data-testid="area" />,
|
|
16
|
-
Pie: () => <div data-testid="pie" />,
|
|
17
|
-
Scatter: () => <div data-testid="scatter" />,
|
|
18
|
-
Cell: () => <div data-testid="cell" />,
|
|
19
|
-
XAxis: () => <div data-testid="x-axis" />,
|
|
20
|
-
YAxis: () => <div data-testid="y-axis" />,
|
|
21
|
-
CartesianGrid: () => <div data-testid="grid" />,
|
|
22
|
-
Tooltip: () => <div data-testid="tooltip" />,
|
|
23
|
-
Legend: () => <div data-testid="legend" />,
|
|
24
|
-
ReferenceLine: () => <div data-testid="reference-line" />,
|
|
25
|
-
ReferenceArea: () => <div data-testid="reference-area" />,
|
|
26
|
-
Brush: () => <div data-testid="brush" />,
|
|
27
|
-
}))
|
|
28
|
-
|
|
29
|
-
// Mock data for testing
|
|
30
|
-
const mockData = [
|
|
31
|
-
{ name: 'Jan', value: 400, revenue: 2400 },
|
|
32
|
-
{ name: 'Feb', value: 300, revenue: 1398 },
|
|
33
|
-
{ name: 'Mar', value: 200, revenue: 9800 },
|
|
34
|
-
{ name: 'Apr', value: 278, revenue: 3908 },
|
|
35
|
-
{ name: 'May', value: 189, revenue: 4800 },
|
|
36
|
-
{ name: 'Jun', value: 239, revenue: 3800 },
|
|
37
|
-
]
|
|
38
|
-
|
|
39
|
-
const mockSeries = [
|
|
40
|
-
{
|
|
41
|
-
dataKey: 'value',
|
|
42
|
-
name: 'Users',
|
|
43
|
-
color: '#8884d8',
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
dataKey: 'revenue',
|
|
47
|
-
name: 'Revenue',
|
|
48
|
-
color: '#82ca9d',
|
|
49
|
-
},
|
|
50
|
-
]
|
|
51
|
-
|
|
52
|
-
describe('AdvancedChart', () => {
|
|
53
|
-
it('renders without crashing', () => {
|
|
54
|
-
render(
|
|
55
|
-
<AdvancedChart
|
|
56
|
-
data={mockData}
|
|
57
|
-
series={mockSeries}
|
|
58
|
-
type="line"
|
|
59
|
-
/>
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
expect(screen.getByText('Advanced Chart')).toBeInTheDocument()
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('renders with custom title', () => {
|
|
66
|
-
render(
|
|
67
|
-
<AdvancedChart
|
|
68
|
-
data={mockData}
|
|
69
|
-
series={mockSeries}
|
|
70
|
-
type="line"
|
|
71
|
-
title="Custom Chart Title"
|
|
72
|
-
/>
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
expect(screen.getByText('Custom Chart Title')).toBeInTheDocument()
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
it('renders with subtitle', () => {
|
|
79
|
-
render(
|
|
80
|
-
<AdvancedChart
|
|
81
|
-
data={mockData}
|
|
82
|
-
series={mockSeries}
|
|
83
|
-
type="line"
|
|
84
|
-
title="Chart Title"
|
|
85
|
-
subtitle="Chart Subtitle"
|
|
86
|
-
/>
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
expect(screen.getByText('Chart Subtitle')).toBeInTheDocument()
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
it('renders line chart type', () => {
|
|
93
|
-
render(
|
|
94
|
-
<AdvancedChart
|
|
95
|
-
data={mockData}
|
|
96
|
-
series={mockSeries}
|
|
97
|
-
type="line"
|
|
98
|
-
/>
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
expect(screen.getByTestId('line-chart')).toBeInTheDocument()
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
it('renders bar chart type', () => {
|
|
105
|
-
render(
|
|
106
|
-
<AdvancedChart
|
|
107
|
-
data={mockData}
|
|
108
|
-
series={mockSeries}
|
|
109
|
-
type="bar"
|
|
110
|
-
/>
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
expect(screen.getByTestId('bar-chart')).toBeInTheDocument()
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
it('renders area chart type', () => {
|
|
117
|
-
render(
|
|
118
|
-
<AdvancedChart
|
|
119
|
-
data={mockData}
|
|
120
|
-
series={mockSeries}
|
|
121
|
-
type="area"
|
|
122
|
-
/>
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
expect(screen.getByTestId('area-chart')).toBeInTheDocument()
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
it('renders pie chart type', () => {
|
|
129
|
-
render(
|
|
130
|
-
<AdvancedChart
|
|
131
|
-
data={mockData}
|
|
132
|
-
series={mockSeries}
|
|
133
|
-
type="pie"
|
|
134
|
-
/>
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
expect(screen.getByTestId('pie-chart')).toBeInTheDocument()
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
it('renders scatter chart type', () => {
|
|
141
|
-
render(
|
|
142
|
-
<AdvancedChart
|
|
143
|
-
data={mockData}
|
|
144
|
-
series={mockSeries}
|
|
145
|
-
type="scatter"
|
|
146
|
-
/>
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
expect(screen.getByTestId('scatter-chart')).toBeInTheDocument()
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
it('shows loading state', () => {
|
|
153
|
-
render(
|
|
154
|
-
<AdvancedChart
|
|
155
|
-
data={mockData}
|
|
156
|
-
series={mockSeries}
|
|
157
|
-
type="line"
|
|
158
|
-
loading={true}
|
|
159
|
-
/>
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
expect(screen.getByText('Loading chart...')).toBeInTheDocument()
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
it('shows error state', () => {
|
|
166
|
-
render(
|
|
167
|
-
<AdvancedChart
|
|
168
|
-
data={mockData}
|
|
169
|
-
series={mockSeries}
|
|
170
|
-
type="line"
|
|
171
|
-
error="Something went wrong"
|
|
172
|
-
/>
|
|
173
|
-
)
|
|
174
|
-
|
|
175
|
-
expect(screen.getByText('Something went wrong')).toBeInTheDocument()
|
|
176
|
-
expect(screen.getByText('Retry')).toBeInTheDocument()
|
|
177
|
-
})
|
|
178
|
-
|
|
179
|
-
it('calls onRefresh when refresh button is clicked', () => {
|
|
180
|
-
const mockOnRefresh = jest.fn()
|
|
181
|
-
|
|
182
|
-
render(
|
|
183
|
-
<AdvancedChart
|
|
184
|
-
data={mockData}
|
|
185
|
-
series={mockSeries}
|
|
186
|
-
type="line"
|
|
187
|
-
onRefresh={mockOnRefresh}
|
|
188
|
-
/>
|
|
189
|
-
)
|
|
190
|
-
|
|
191
|
-
const refreshButton = screen.getByRole('button', { name: /refresh/i })
|
|
192
|
-
fireEvent.click(refreshButton)
|
|
193
|
-
|
|
194
|
-
expect(mockOnRefresh).toHaveBeenCalled()
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
it('calls onExport when export button is clicked', () => {
|
|
198
|
-
const mockOnExport = jest.fn()
|
|
199
|
-
|
|
200
|
-
render(
|
|
201
|
-
<AdvancedChart
|
|
202
|
-
data={mockData}
|
|
203
|
-
series={mockSeries}
|
|
204
|
-
type="line"
|
|
205
|
-
onExport={mockOnExport}
|
|
206
|
-
/>
|
|
207
|
-
)
|
|
208
|
-
|
|
209
|
-
const exportButton = screen.getByRole('button', { name: /download/i })
|
|
210
|
-
fireEvent.click(exportButton)
|
|
211
|
-
|
|
212
|
-
expect(mockOnExport).toHaveBeenCalledWith('png')
|
|
213
|
-
})
|
|
214
|
-
|
|
215
|
-
it('displays trend indicator', () => {
|
|
216
|
-
render(
|
|
217
|
-
<AdvancedChart
|
|
218
|
-
data={mockData}
|
|
219
|
-
series={mockSeries}
|
|
220
|
-
type="line"
|
|
221
|
-
title="Revenue Chart"
|
|
222
|
-
/>
|
|
223
|
-
)
|
|
224
|
-
|
|
225
|
-
// Should display trend percentage
|
|
226
|
-
expect(screen.getByText(/%/)).toBeInTheDocument()
|
|
227
|
-
})
|
|
228
|
-
|
|
229
|
-
it('renders with custom height', () => {
|
|
230
|
-
render(
|
|
231
|
-
<AdvancedChart
|
|
232
|
-
data={mockData}
|
|
233
|
-
series={mockSeries}
|
|
234
|
-
type="line"
|
|
235
|
-
height={600}
|
|
236
|
-
/>
|
|
237
|
-
)
|
|
238
|
-
|
|
239
|
-
expect(screen.getByTestId('responsive-container')).toBeInTheDocument()
|
|
240
|
-
})
|
|
241
|
-
|
|
242
|
-
it('handles responsive mode', () => {
|
|
243
|
-
render(
|
|
244
|
-
<AdvancedChart
|
|
245
|
-
data={mockData}
|
|
246
|
-
series={mockSeries}
|
|
247
|
-
type="line"
|
|
248
|
-
responsive={true}
|
|
249
|
-
/>
|
|
250
|
-
)
|
|
251
|
-
|
|
252
|
-
expect(screen.getByTestId('responsive-container')).toBeInTheDocument()
|
|
253
|
-
})
|
|
254
|
-
|
|
255
|
-
it('handles non-responsive mode', () => {
|
|
256
|
-
render(
|
|
257
|
-
<AdvancedChart
|
|
258
|
-
data={mockData}
|
|
259
|
-
series={mockSeries}
|
|
260
|
-
type="line"
|
|
261
|
-
responsive={false}
|
|
262
|
-
/>
|
|
263
|
-
)
|
|
264
|
-
|
|
265
|
-
expect(screen.queryByTestId('responsive-container')).not.toBeInTheDocument()
|
|
266
|
-
})
|
|
267
|
-
|
|
268
|
-
it('applies custom className', () => {
|
|
269
|
-
render(
|
|
270
|
-
<AdvancedChart
|
|
271
|
-
data={mockData}
|
|
272
|
-
series={mockSeries}
|
|
273
|
-
type="line"
|
|
274
|
-
className="custom-chart"
|
|
275
|
-
/>
|
|
276
|
-
)
|
|
277
|
-
|
|
278
|
-
const chartContainer = screen.getByText('Advanced Chart').closest('div')
|
|
279
|
-
expect(chartContainer).toHaveClass('custom-chart')
|
|
280
|
-
})
|
|
281
|
-
})
|