Fix TypeScript typecheck errors
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
|
||||
const fixtures = vi.hoisted(() => ({
|
||||
event: {
|
||||
@@ -74,7 +75,11 @@ vi.mock('../components/MobileShell', () => ({
|
||||
|
||||
vi.mock('../components/Primitives', () => ({
|
||||
MobileCard: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||
CTAButton: ({ label }: { label: string }) => <button type="button">{label}</button>,
|
||||
CTAButton: ({ label, onPress, disabled }: { label: string; onPress?: () => void; disabled?: boolean }) => (
|
||||
<button type="button" onClick={onPress} disabled={disabled}>
|
||||
{label}
|
||||
</button>
|
||||
),
|
||||
PillBadge: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||
}));
|
||||
|
||||
@@ -116,6 +121,7 @@ vi.mock('../theme', () => ({
|
||||
}));
|
||||
|
||||
import MobileQrPrintPage from '../QrPrintPage';
|
||||
import { createQrInvite } from '../../api';
|
||||
|
||||
describe('MobileQrPrintPage', () => {
|
||||
it('renders QR overview content', async () => {
|
||||
@@ -125,4 +131,19 @@ describe('MobileQrPrintPage', () => {
|
||||
expect(screen.getByText('Schritt 1: Format wählen')).toBeInTheDocument();
|
||||
expect(screen.getAllByText('Neuen QR-Link erstellen').length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('requires confirmation before creating a new QR link', async () => {
|
||||
const user = userEvent.setup();
|
||||
const confirmSpy = vi.fn().mockReturnValue(false);
|
||||
window.confirm = confirmSpy;
|
||||
|
||||
render(<MobileQrPrintPage />);
|
||||
|
||||
const createButton = await screen.findByRole('button', { name: 'Neuen QR-Link erstellen' });
|
||||
await user.click(createButton);
|
||||
|
||||
expect(confirmSpy).toHaveBeenCalled();
|
||||
expect(confirmSpy).toHaveBeenCalledWith(expect.stringContaining('Ausdrucke'));
|
||||
expect(createQrInvite).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user