54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import React from 'react';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
import { render, screen } from '@testing-library/react';
|
|
|
|
class ResizeObserverMock {
|
|
observe() {}
|
|
unobserve() {}
|
|
disconnect() {}
|
|
}
|
|
|
|
global.ResizeObserver = ResizeObserverMock as unknown as typeof ResizeObserver;
|
|
|
|
vi.mock('@inertiajs/react', () => ({
|
|
usePage: () => ({ props: { locale: 'de' } }),
|
|
Link: ({ children, ...props }: { children: React.ReactNode }) => <a {...props}>{children}</a>,
|
|
}));
|
|
|
|
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;
|
|
},
|
|
}),
|
|
}));
|
|
|
|
vi.mock('react-hot-toast', () => ({
|
|
default: {
|
|
error: vi.fn(),
|
|
success: vi.fn(),
|
|
},
|
|
}));
|
|
|
|
import LoginForm from '../LoginForm';
|
|
|
|
describe('LoginForm', () => {
|
|
it('renders Google login option when packageId is provided', () => {
|
|
render(<LoginForm packageId={12} />);
|
|
|
|
expect(screen.getByText('login.google_cta')).toBeInTheDocument();
|
|
});
|
|
|
|
it('does not render Google login option without packageId', () => {
|
|
render(<LoginForm />);
|
|
|
|
expect(screen.queryByText('login.google_cta')).not.toBeInTheDocument();
|
|
});
|
|
});
|