Merge branch 'add-search-tests' into 'next'
Add tests for Search See merge request soapbox-pub/soapbox-fe!1190
This commit is contained in:
commit
dbe6a0c415
5 changed files with 32 additions and 1 deletions
|
@ -125,7 +125,7 @@ const Account = ({
|
||||||
const LinkEl: any = showProfileHoverCard ? Link : 'div';
|
const LinkEl: any = showProfileHoverCard ? Link : 'div';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='flex-shrink-0 group block w-full overflow-hidden' ref={overflowRef}>
|
<div data-testid='account' className='flex-shrink-0 group block w-full overflow-hidden' ref={overflowRef}>
|
||||||
<HStack alignItems={actionAlignment} justifyContent='between'>
|
<HStack alignItems={actionAlignment} justifyContent='between'>
|
||||||
<HStack alignItems='center' space={3} grow>
|
<HStack alignItems='center' space={3} grow>
|
||||||
<ProfilePopper
|
<ProfilePopper
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,28 @@
|
||||||
|
import userEvent from '@testing-library/user-event';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import { __stub } from 'soapbox/api';
|
||||||
|
|
||||||
|
import { render, screen } 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');
|
||||||
|
|
||||||
|
expect(screen.getByLabelText('Search')).toHaveValue('@jus');
|
||||||
|
expect(screen.getByTestId('account')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
|
@ -8,3 +8,6 @@ afterEach(() => clearApiMocks());
|
||||||
|
|
||||||
// Mock external dependencies
|
// Mock external dependencies
|
||||||
jest.mock('uuid', () => ({ v4: jest.fn(() => 1) }));
|
jest.mock('uuid', () => ({ v4: jest.fn(() => 1) }));
|
||||||
|
|
||||||
|
const intersectionObserverMock = () => ({ observe: () => null, disconnect: () => null });
|
||||||
|
window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock);
|
||||||
|
|
Loading…
Reference in a new issue