Skip to content
Snippets Groups Projects

Feature/searchparams

Merged Tadeusz Miesiąc requested to merge feature/searchparams into feature/multisearch
1 unresolved thread
11 files
+ 56
42
Compare changes
  • Side-by-side
  • Inline
Files
11
import { StoreType } from '@/redux/store';
import { useRouter } from 'next/router';
import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore';
import { fireEvent, render, screen } from '@testing-library/react';
import { SearchBar } from './SearchBar.component';
@@ -18,6 +19,14 @@ const renderComponent = (): { store: StoreType } => {
);
};
jest.mock('next/router', () => ({
useRouter: jest.fn(),
}));
(useRouter as jest.Mock).mockReturnValue({
query: {},
});
describe('SearchBar - component', () => {
it('should let user type text', () => {
renderComponent();
@@ -50,4 +59,11 @@ describe('SearchBar - component', () => {
expect(input).toBeDisabled();
});
it('should set initial search value to match searchValue query param', () => {
(useRouter as jest.Mock).mockReturnValue({
query: { searchValue: 'aspirin;nadh' },
});
renderComponent();
});
});
Loading