From 1e982fb02a9967e0efdc76c93a44798a9f2dcb43 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Tue, 24 May 2022 16:44:29 +0200
Subject: chore: add a search form when posts list prints no results

---
 .../organisms/layout/posts-list.test.tsx           | 29 +++++++++++++++++++---
 1 file changed, 25 insertions(+), 4 deletions(-)

(limited to 'src/components/organisms/layout/posts-list.test.tsx')

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();
+  });
 });
-- 
cgit v1.2.3

