pleroma/app/soapbox/features/compose/components/__tests__/search.test.tsx

31 lines
856 B
TypeScript
Raw Normal View History

2022-04-06 07:10:21 -07:00
import userEvent from '@testing-library/user-event';
import React from 'react';
import { __stub } from 'soapbox/api';
2022-12-29 07:39:43 -08:00
import { render, screen, waitFor } from '../../../../jest/test-helpers';
2022-04-06 07:10:21 -07:00
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');
2022-12-29 07:39:43 -08:00
await waitFor(() => {
expect(screen.getByLabelText('Search')).toHaveValue('@jus');
expect(screen.getByTestId('account')).toBeInTheDocument();
});
2022-04-06 07:10:21 -07:00
});
});