77 lines
2.1 KiB
TypeScript
77 lines
2.1 KiB
TypeScript
import React from 'react';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
import { render, screen } from '@testing-library/react';
|
|
|
|
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('@tamagui/button', () => ({
|
|
Button: ({ children, onPress, ...rest }: { children: React.ReactNode; onPress?: () => void }) => (
|
|
<button type="button" onClick={onPress} {...rest}>
|
|
{children}
|
|
</button>
|
|
),
|
|
}));
|
|
|
|
vi.mock('../components/AppShell', () => ({
|
|
default: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
|
}));
|
|
|
|
vi.mock('../context/EventDataContext', () => ({
|
|
useEventData: () => ({ token: 'demo', event: { name: 'Demo Event' } }),
|
|
}));
|
|
|
|
vi.mock('../hooks/usePollStats', () => ({
|
|
usePollStats: () => ({ stats: { onlineGuests: 3 } }),
|
|
}));
|
|
|
|
vi.mock('../services/eventLink', () => ({
|
|
buildEventShareLink: () => 'https://example.test/e/demo',
|
|
}));
|
|
|
|
vi.mock('../services/qrApi', () => ({
|
|
fetchEventQrCode: () => Promise.resolve({ qr_code_data_url: '' }),
|
|
}));
|
|
|
|
vi.mock('../lib/guestTheme', () => ({
|
|
useGuestThemeVariant: () => ({ isDark: false }),
|
|
}));
|
|
|
|
vi.mock('../lib/bento', () => ({
|
|
getBentoSurfaceTokens: () => ({
|
|
borderColor: '#eee',
|
|
borderBottomColor: '#ddd',
|
|
backgroundColor: '#fff',
|
|
shadow: 'none',
|
|
}),
|
|
}));
|
|
|
|
vi.mock('../lib/toast', () => ({
|
|
pushGuestToast: vi.fn(),
|
|
}));
|
|
|
|
vi.mock('@/guest/i18n/useTranslation', () => ({
|
|
useTranslation: () => ({
|
|
t: (key: string, options?: unknown, fallback?: string) => {
|
|
if (typeof fallback === 'string') return fallback;
|
|
if (typeof options === 'string') return options;
|
|
return key;
|
|
},
|
|
}),
|
|
}));
|
|
|
|
import ShareScreen from '../screens/ShareScreen';
|
|
|
|
describe('ShareScreen', () => {
|
|
it('renders invite header', async () => {
|
|
render(<ShareScreen />);
|
|
expect(await screen.findByText('Invite guests')).toBeInTheDocument();
|
|
});
|
|
});
|