diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-11-03 23:03:06 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-11 18:15:27 +0100 |
| commit | ce4a18899f24ba89b63ef743476ec0dbf1999ecf (patch) | |
| tree | 003a59ee62bc5f1f97110926559d941a978090ac /src/components/organisms/layout/posts-list.test.tsx | |
| parent | ddd45e29745b73e7fe1684e197dcff598b375644 (diff) | |
refactor(components): rewrite SearchForm component
* remove searchPage prop (the consumer should handle the submit)
* change onSubmit type
* use `useForm` hook to handle the form
Diffstat (limited to 'src/components/organisms/layout/posts-list.test.tsx')
| -rw-r--r-- | src/components/organisms/layout/posts-list.test.tsx | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/src/components/organisms/layout/posts-list.test.tsx b/src/components/organisms/layout/posts-list.test.tsx index d5273fc..fabf31f 100644 --- a/src/components/organisms/layout/posts-list.test.tsx +++ b/src/components/organisms/layout/posts-list.test.tsx @@ -1,47 +1,31 @@ import { describe, expect, it } from '@jest/globals'; -import { render, screen } from '../../../../tests/utils'; +import { render, screen as rtlScreen } from '../../../../tests/utils'; import { PostsList } from './posts-list'; -import { posts, searchPage } from './posts-list.fixture'; +import { posts } from './posts-list.fixture'; describe('PostsList', () => { it('renders the correct number of posts', () => { - render( - <PostsList posts={posts} total={posts.length} searchPage={searchPage} /> - ); - expect(screen.getAllByRole('article')).toHaveLength(posts.length); + render(<PostsList posts={posts} total={posts.length} />); + expect(rtlScreen.getAllByRole('article')).toHaveLength(posts.length); }); it('renders the number of loaded posts', () => { - render( - <PostsList posts={posts} total={posts.length} searchPage={searchPage} /> - ); + render(<PostsList posts={posts} total={posts.length} />); const info = `${posts.length} loaded articles out of a total of ${posts.length}`; - expect(screen.getByText(info)).toBeInTheDocument(); + expect(rtlScreen.getByText(info)).toBeInTheDocument(); }); it('renders a load more button', () => { render( - <PostsList - posts={posts} - total={posts.length} - showLoadMoreBtn={true} - searchPage={searchPage} - /> + <PostsList posts={posts} total={posts.length} showLoadMoreBtn={true} /> ); expect( - screen.getByRole('button', { name: /Load more/i }) + rtlScreen.getByRole('button', { name: /Load more/i }) ).toBeInTheDocument(); }); it('renders a search form if no results', () => { - render( - <PostsList - posts={[]} - total={0} - showLoadMoreBtn={true} - searchPage={searchPage} - /> - ); - expect(screen.getByRole('searchbox')).toBeInTheDocument(); + render(<PostsList posts={[]} total={0} showLoadMoreBtn={true} />); + expect(rtlScreen.getByRole('searchbox')).toBeInTheDocument(); }); }); |
