Repository: gitify-app/gitify
Pull request #590 (2023-06-05 19:23:16)

chore: improve tests for sidebar


Patch:
diff --git a/src/components/Logo.tsx b/src/components/Logo.tsx
index 3afa0ffd..1193ba82 100644
--- a/src/components/Logo.tsx
+++ b/src/components/Logo.tsx
@@ -12,7 +12,7 @@ const LIGHT_GRADIENT_END = '#FFFFFF';
 const DARK_GRADIENT_START = '#22283B';
 const DARK_GRADIENT_END = '#555B6E';
 
-export const Logo = ({ isDark, onClick, className = '' }: IProps) => (
+export const Logo = ({ isDark, onClick, className = '', ...props }: IProps) => (
   <svg
     className={className}
     onClick={() => onClick && onClick()}
@@ -20,6 +20,7 @@ export const Logo = ({ isDark, onClick, className = '' }: IProps) => (
     xmlnsXlink="http://www.w3.org/1999/xlink"
     viewBox="0 0 500 500"
     role="logo"
+    {...props}
   >
     <defs>
       <linearGradient
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index c0a404e1..c5cf4e71 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -43,6 +43,7 @@ export const Sidebar: React.FC = () => {
       <div className="flex flex-col flex-1 items-center py-4">
         <Logo
           className="w-5 my-3 mx-auto cursor-pointer"
+          data-testid="gitify-logo"
           onClick={onOpenBrowser}
         />
 
diff --git a/src/utils/constants.ts b/src/utils/constants.ts
index 26a2eddb..70125cf9 100644
--- a/src/utils/constants.ts
+++ b/src/utils/constants.ts
@@ -8,7 +8,7 @@ export const Constants = {
     clientSecret: process.env.OAUTH_CLIENT_SECRET,
   },
 
-  REPO_SLUG: 'manosim/gitify',
+  REPO_SLUG: 'gitify-app/gitify',
 
   // Storage
   STORAGE_KEY: 'gitify-storage',


Test patch:
diff --git a/src/components/Sidebar.test.tsx b/src/components/Sidebar.test.tsx
index 6f8fbea8..5c34e145 100644
--- a/src/components/Sidebar.test.tsx
+++ b/src/components/Sidebar.test.tsx
@@ -1,4 +1,4 @@
-import { fireEvent, render } from '@testing-library/react';
+import { fireEvent, render, screen } from '@testing-library/react';
 import { createMemoryHistory } from 'history';
 import * as React from 'react';
 import { Router } from 'react-router';
@@ -102,6 +102,34 @@ describe('components/Sidebar.tsx', () => {
     );
   });
 
+  it('should quit the app', () => {
+    const { getByLabelText } = render(
+      <AppContext.Provider value={{ isLoggedIn: false, notifications: [] }}>
+        <MemoryRouter>
+          <Sidebar />
+        </MemoryRouter>
+      </AppContext.Provider>
+    );
+    fireEvent.click(getByLabelText('Quit App'));
+    expect(ipcRenderer.send).toHaveBeenCalledTimes(1);
+    expect(ipcRenderer.send).toHaveBeenCalledWith('app-quit');
+  });
+
+  it('should open the gitify repository', () => {
+    render(
+      <AppContext.Provider value={{ isLoggedIn: false, notifications: [] }}>
+        <MemoryRouter>
+          <Sidebar />
+        </MemoryRouter>
+      </AppContext.Provider>
+    );
+    fireEvent.click(screen.getByTestId('gitify-logo'));
+    expect(shell.openExternal).toHaveBeenCalledTimes(1);
+    expect(shell.openExternal).toHaveBeenCalledWith(
+      'https://github.com/gitify-app/gitify'
+    );
+  });
+
   describe('should render the notifications icon', () => {
     it('when there are 0 notifications', () => {
       const { getByLabelText } = render(
diff --git a/src/components/__snapshots__/Sidebar.test.tsx.snap b/src/components/__snapshots__/Sidebar.test.tsx.snap
index 682ebbb1..5ff88d12 100644
--- a/src/components/__snapshots__/Sidebar.test.tsx.snap
+++ b/src/components/__snapshots__/Sidebar.test.tsx.snap
@@ -9,6 +9,7 @@ exports[`components/Sidebar.tsx should render itself & its children (logged in)
   >
     <svg
       className="w-5 my-3 mx-auto cursor-pointer"
+      data-testid="gitify-logo"
       onClick={[Function]}
       role="logo"
       viewBox="0 0 500 500"
@@ -127,6 +128,7 @@ exports[`components/Sidebar.tsx should render itself & its children (logged out)
   >
     <svg
       className="w-5 my-3 mx-auto cursor-pointer"
+      data-testid="gitify-logo"
       onClick={[Function]}
       role="logo"
       viewBox="0 0 500 500"