UNPKG

@letanure/resend-cli

Version:

A command-line interface for Resend email API

54 lines 2.63 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { describe, expect, it, vi } from 'vitest'; import { renderWithProviders } from '../../../../utils/test-utils.js'; import { Form } from '../Form.js'; describe('Email Send Form', () => { const mockOnExit = vi.fn(); it('renders form with email fields', () => { const { lastFrame } = renderWithProviders(_jsx(Form, { onExit: mockOnExit })); const output = lastFrame(); expect(output).toContain('From'); expect(output).toContain('To'); expect(output).toContain('Subject'); expect(output).toContain('HTML Content'); expect(output).toContain('Text Content'); }); it('exits when ESC is pressed', async () => { const { stdin } = renderWithProviders(_jsx(Form, { onExit: mockOnExit })); await stdin.write('\x1B'); // ESC key expect(mockOnExit).toHaveBeenCalled(); }); it('shows dry-run banner in dry-run mode', () => { const { lastFrame } = renderWithProviders(_jsx(Form, { onExit: mockOnExit }), { isDryRun: true }); expect(lastFrame()).toContain('DRY RUN MODE'); }); it('shows validation errors when submitting empty form', async () => { const { lastFrame, stdin } = renderWithProviders(_jsx(Form, { onExit: mockOnExit })); // Submit without filling fields await stdin.write('\r'); // Enter key await new Promise((resolve) => setTimeout(resolve, 50)); const output = lastFrame(); expect(output).toContain('Required'); // Validation error }); it('renders correctly in dry-run mode', () => { const { lastFrame } = renderWithProviders(_jsx(Form, { onExit: mockOnExit }), { isDryRun: true }); const output = lastFrame(); expect(output).toContain('DRY RUN MODE'); expect(output).toContain('From'); }); it('renders correctly in normal mode', () => { const { lastFrame } = renderWithProviders(_jsx(Form, { onExit: mockOnExit }), { isDryRun: false }); const output = lastFrame(); expect(output).not.toContain('DRY RUN MODE'); expect(output).toContain('From'); }); it('matches snapshot in normal mode', () => { const { lastFrame } = renderWithProviders(_jsx(Form, { onExit: mockOnExit }), { isDryRun: false }); expect(lastFrame()).toMatchSnapshot(); }); it('matches snapshot in dry-run mode', () => { const { lastFrame } = renderWithProviders(_jsx(Form, { onExit: mockOnExit }), { isDryRun: true }); expect(lastFrame()).toMatchSnapshot(); }); }); //# sourceMappingURL=Form.test.js.map