pleroma/app/soapbox/features/compose/components/__tests__/search.test.tsx
2022-12-29 10:39:43 -05:00

30 lines
856 B
TypeScript

import userEvent from '@testing-library/user-event';
import React from 'react';
import { __stub } from 'soapbox/api';
import { render, screen, waitFor } from '../../../../jest/test-helpers';
import Search from '../search';
describe('<Search />', () => {
it('successfully renders', async() => {
render(<Search autosuggest />);
expect(screen.getByLabelText('Search')).toBeInTheDocument();
});
it('handles onChange', async() => {
__stub(mock => {
mock.onGet('/api/v1/accounts/search').reply(200, [{ id: 1 }]);
});
const user = userEvent.setup();
render(<Search autosuggest />);
await user.type(screen.getByLabelText('Search'), '@jus');
await waitFor(() => {
expect(screen.getByLabelText('Search')).toHaveValue('@jus');
expect(screen.getByTestId('account')).toBeInTheDocument();
});
});
});