72 lines
2.1 KiB
TypeScript
72 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, ...rest }: { children: React.ReactNode }) => (
|
|
<button type="button" {...rest}>
|
|
{children}
|
|
</button>
|
|
),
|
|
}));
|
|
|
|
vi.mock('../components/AppShell', () => ({
|
|
default: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
|
}));
|
|
|
|
vi.mock('../context/EventDataContext', () => ({
|
|
useEventData: () => ({
|
|
token: 'demo-token',
|
|
event: { name: 'Demo Event', join_token: 'demo-token' },
|
|
}),
|
|
}));
|
|
|
|
vi.mock('../hooks/usePollStats', () => ({
|
|
usePollStats: () => ({
|
|
stats: {
|
|
onlineGuests: 12,
|
|
tasksSolved: 0,
|
|
guestCount: 40,
|
|
likesCount: 120,
|
|
latestPhotoAt: null,
|
|
},
|
|
}),
|
|
}));
|
|
|
|
vi.mock('../services/qrApi', () => ({
|
|
fetchEventQrCode: () => Promise.resolve({ qr_code_data_url: 'data:image/png;base64,abc' }),
|
|
}));
|
|
|
|
vi.mock('@/guest/i18n/useTranslation', () => ({
|
|
useTranslation: () => ({
|
|
t: (key: string, arg2?: Record<string, string | number> | string, arg3?: string) =>
|
|
typeof arg2 === 'string' || arg2 === undefined ? (arg2 ?? arg3 ?? key) : (arg3 ?? key),
|
|
}),
|
|
}));
|
|
|
|
vi.mock('@/hooks/use-appearance', () => ({
|
|
useAppearance: () => ({ resolved: 'light' }),
|
|
}));
|
|
|
|
import ShareScreen from '../screens/ShareScreen';
|
|
|
|
describe('ShareScreen', () => {
|
|
it('shows guests online from stats', async () => {
|
|
render(<ShareScreen />);
|
|
|
|
expect(await screen.findByText('12')).toBeInTheDocument();
|
|
expect(screen.getByText('Guests joined')).toBeInTheDocument();
|
|
expect(screen.getByText('Guests online')).toBeInTheDocument();
|
|
expect(screen.getByAltText('Event QR code')).toBeInTheDocument();
|
|
});
|
|
});
|