100 lines
2.8 KiB
TypeScript
100 lines
2.8 KiB
TypeScript
import React from 'react';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
import { render, screen } from '@testing-library/react';
|
|
|
|
const navigateMock = vi.fn();
|
|
|
|
vi.mock('react-router-dom', () => ({
|
|
useNavigate: () => navigateMock,
|
|
Navigate: ({ to }: { to: string }) => <div>{to}</div>,
|
|
}));
|
|
|
|
vi.mock('react-i18next', () => ({
|
|
useTranslation: () => ({
|
|
t: (key: string, fallback?: string | Record<string, unknown>) => {
|
|
if (typeof fallback === 'string') {
|
|
return fallback;
|
|
}
|
|
if (fallback && typeof fallback === 'object' && typeof fallback.defaultValue === 'string') {
|
|
return fallback.defaultValue;
|
|
}
|
|
return key;
|
|
},
|
|
i18n: { language: 'de' },
|
|
}),
|
|
}));
|
|
|
|
vi.mock('../../context/EventContext', () => ({
|
|
useEventContext: () => ({
|
|
events: [{ slug: 'demo-event', event_date: '2026-02-19' }],
|
|
activeEvent: null,
|
|
hasEvents: true,
|
|
selectEvent: vi.fn(),
|
|
}),
|
|
}));
|
|
|
|
vi.mock('../../lib/events', () => ({
|
|
resolveEventDisplayName: () => 'Demo Event',
|
|
formatEventDate: () => '19. Feb. 2026',
|
|
}));
|
|
|
|
vi.mock('../components/MobileShell', () => ({
|
|
MobileShell: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
|
}));
|
|
|
|
vi.mock('../components/Primitives', () => ({
|
|
CTAButton: ({ label }: { label: string }) => <button type="button">{label}</button>,
|
|
}));
|
|
|
|
vi.mock('@tamagui/card', () => ({
|
|
Card: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
|
}));
|
|
|
|
vi.mock('@tamagui/group', () => ({
|
|
YGroup: Object.assign(({ children }: { children: React.ReactNode }) => <div>{children}</div>, {
|
|
Item: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
|
}),
|
|
}));
|
|
|
|
vi.mock('@tamagui/list-item', () => ({
|
|
ListItem: ({ title, iconAfter }: { title?: React.ReactNode; iconAfter?: React.ReactNode }) => (
|
|
<div>
|
|
{title}
|
|
{iconAfter}
|
|
</div>
|
|
),
|
|
}));
|
|
|
|
vi.mock('@tamagui/stacks', () => ({
|
|
YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
|
XStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
|
}));
|
|
|
|
vi.mock('@tamagui/text', () => ({
|
|
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
|
|
}));
|
|
|
|
vi.mock('../theme', () => ({
|
|
useAdminTheme: () => ({
|
|
text: '#111827',
|
|
muted: '#6b7280',
|
|
border: '#e5e7eb',
|
|
primary: '#ff5a5f',
|
|
surface: '#ffffff',
|
|
surfaceMuted: '#f9fafb',
|
|
shadow: 'rgba(15,23,42,0.12)',
|
|
}),
|
|
}));
|
|
|
|
import MobileUploadsTabPage from '../UploadsTabPage';
|
|
|
|
describe('MobileUploadsTabPage', () => {
|
|
it('renders the event picker list', () => {
|
|
render(<MobileUploadsTabPage />);
|
|
|
|
expect(screen.getByText('Pick an event to manage uploads')).toBeInTheDocument();
|
|
expect(screen.getByText('Demo Event')).toBeInTheDocument();
|
|
expect(screen.getByText('Open')).toBeInTheDocument();
|
|
});
|
|
});
|