import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { Terminal } from '.';
describe(Terminal, () => {
it('generates correct copyCmd from single command', async () => {
render(
<>
>
);
expect(screen.getByText('Copy')).toBeVisible();
const user = userEvent.setup();
await user.click(screen.getByText('Copy'));
await user.click(screen.getByRole('textbox'));
await user.paste();
expect((screen.getByRole('textbox') as HTMLTextAreaElement).value).toBe(
'expo install expo-updates'
);
});
it('generates correct copyCmd from single command with comments and blank lines', async () => {
render(
<>
>
);
expect(screen.getByText('Copy')).toBeVisible();
const user = userEvent.setup();
await user.click(screen.getByText('Copy'));
await user.click(screen.getByRole('textbox'));
await user.paste();
expect((screen.getByRole('textbox') as HTMLTextAreaElement).value).toBe(
'expo install expo-dev-client'
);
});
it('do not generate copyCmd if first line is a comment', () => {
render();
expect(screen.queryByText('Copy')).toBe(null);
});
it('do not generate copyCmd if there is more than one command', () => {
render();
expect(screen.queryByText('Copy')).toBe(null);
});
});