diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-05-24 16:44:29 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-05-24 16:44:29 +0200 |
| commit | 1e982fb02a9967e0efdc76c93a44798a9f2dcb43 (patch) | |
| tree | b9a526ade81feee20cf18404e2a7053ccff6c999 /src/components/organisms/layout/posts-list.test.tsx | |
| parent | c347190a4307c172d15dac156da86567098035f6 (diff) | |
chore: add a search form when posts list prints no results
Diffstat (limited to 'src/components/organisms/layout/posts-list.test.tsx')
| -rw-r--r-- | src/components/organisms/layout/posts-list.test.tsx | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/components/organisms/layout/posts-list.test.tsx b/src/components/organisms/layout/posts-list.test.tsx index 1bab466..e58a974 100644 --- a/src/components/organisms/layout/posts-list.test.tsx +++ b/src/components/organisms/layout/posts-list.test.tsx @@ -1,25 +1,46 @@ import { render, screen } from '@test-utils'; import PostsList from './posts-list'; -import { posts } from './posts-list.fixture'; +import { posts, searchPage } from './posts-list.fixture'; describe('PostsList', () => { it('renders the correct number of posts', () => { - render(<PostsList posts={posts} total={posts.length} />); + render( + <PostsList posts={posts} total={posts.length} searchPage={searchPage} /> + ); expect(screen.getAllByRole('article')).toHaveLength(posts.length); }); it('renders the number of loaded posts', () => { - render(<PostsList posts={posts} total={posts.length} />); + render( + <PostsList posts={posts} total={posts.length} searchPage={searchPage} /> + ); const info = `${posts.length} loaded articles out of a total of ${posts.length}`; expect(screen.getByText(info)).toBeInTheDocument(); }); it('renders a load more button', () => { render( - <PostsList posts={posts} total={posts.length} showLoadMoreBtn={true} /> + <PostsList + posts={posts} + total={posts.length} + showLoadMoreBtn={true} + searchPage={searchPage} + /> ); expect( screen.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(); + }); }); |
