Repository: gitify-app/gitify
Pull request #1308 (2024-06-22 14:28:42)

test: consistent use of jest


Patch:
diff --git a/src/components/AccountNotifications.tsx b/src/components/AccountNotifications.tsx
index 518e94d8..5d9f1552 100644
--- a/src/components/AccountNotifications.tsx
+++ b/src/components/AccountNotifications.tsx
@@ -101,26 +101,28 @@ export const AccountNotifications: FC<IAccountNotifications> = (
         </div>
       )}
 
-      {showAccountNotifications
-        ? groupByRepository
-          ? Object.values(groupedNotifications).map((repoNotifications) => {
-              const repoSlug = repoNotifications[0].repository.full_name;
+      {showAccountNotifications && (
+        <>
+          {groupByRepository
+            ? Object.values(groupedNotifications).map((repoNotifications) => {
+                const repoSlug = repoNotifications[0].repository.full_name;
 
-              return (
-                <RepositoryNotifications
-                  key={repoSlug}
-                  repoName={repoSlug}
-                  repoNotifications={repoNotifications}
+                return (
+                  <RepositoryNotifications
+                    key={repoSlug}
+                    repoName={repoSlug}
+                    repoNotifications={repoNotifications}
+                  />
+                );
+              })
+            : notifications.map((notification) => (
+                <NotificationRow
+                  key={notification.id}
+                  notification={notification}
                 />
-              );
-            })
-          : notifications.map((notification) => (
-              <NotificationRow
-                key={notification.id}
-                notification={notification}
-              />
-            ))
-        : null}
+              ))}
+        </>
+      )}
     </>
   );
 };
diff --git a/src/components/icons/AuthMethodIcon.tsx b/src/components/icons/AuthMethodIcon.tsx
index 85021bfb..90251bd7 100644
--- a/src/components/icons/AuthMethodIcon.tsx
+++ b/src/components/icons/AuthMethodIcon.tsx
@@ -11,11 +11,9 @@ export interface IAuthMethodIcon {
 export const AuthMethodIcon: FC<IAuthMethodIcon> = (props: IAuthMethodIcon) => {
   return (
     <span title={props.type} className="mr-1">
-      {props.type === 'GitHub App' ? <AppsIcon size={props.size} /> : null}
-      {props.type === 'Personal Access Token' ? (
-        <KeyIcon size={props.size} />
-      ) : null}
-      {props.type === 'OAuth App' ? <PersonIcon size={props.size} /> : null}
+      {props.type === 'GitHub App' && <AppsIcon size={props.size} />}
+      {props.type === 'Personal Access Token' && <KeyIcon size={props.size} />}
+      {props.type === 'OAuth App' && <PersonIcon size={props.size} />}
     </span>
   );
 };
diff --git a/src/components/icons/PlatformIcon.tsx b/src/components/icons/PlatformIcon.tsx
index 3fb34104..7fb50501 100644
--- a/src/components/icons/PlatformIcon.tsx
+++ b/src/components/icons/PlatformIcon.tsx
@@ -11,12 +11,10 @@ export interface IPlatformIcon {
 export const PlatformIcon: FC<IPlatformIcon> = (props: IPlatformIcon) => {
   return (
     <span title={props.type} className="mr-1">
-      {props.type === 'GitHub Cloud' ? (
-        <MarkGithubIcon size={props.size} />
-      ) : null}
-      {props.type === 'GitHub Enterprise Server' ? (
+      {props.type === 'GitHub Cloud' && <MarkGithubIcon size={props.size} />}
+      {props.type === 'GitHub Enterprise Server' && (
         <ServerIcon size={props.size} />
-      ) : null}
+      )}
     </span>
   );
 };
diff --git a/src/utils/auth/utils.ts b/src/utils/auth/utils.ts
index fec3e572..b15b8455 100644
--- a/src/utils/auth/utils.ts
+++ b/src/utils/auth/utils.ts
@@ -28,13 +28,15 @@ export function authGitHub(
       show: true,
     });
 
-    const githubUrl = `https://${authOptions.hostname}/login/oauth/authorize`;
-    const authUrl = `${githubUrl}?client_id=${authOptions.clientId}&scope=${Constants.AUTH_SCOPE}`;
+    const authUrl = new URL(`https://${authOptions.hostname}`);
+    authUrl.pathname = '/login/oauth/authorize';
+    authUrl.searchParams.append('client_id', authOptions.clientId);
+    authUrl.searchParams.append('scope', Constants.AUTH_SCOPE.toString());
 
     const session = authWindow.webContents.session;
     session.clearStorageData();
 
-    authWindow.loadURL(authUrl);
+    authWindow.loadURL(authUrl.toString());
 
     const handleCallback = (url: Link) => {
       const raw_code = /code=([^&]*)/.exec(url) || null;


Test patch:
diff --git a/src/components/AllRead.test.tsx b/src/components/AllRead.test.tsx
index da53fc8c..cd12d4a1 100644
--- a/src/components/AllRead.test.tsx
+++ b/src/components/AllRead.test.tsx
@@ -2,18 +2,12 @@ import { render } from '@testing-library/react';
 import { AllRead } from './AllRead';
 
 describe('components/AllRead.tsx', () => {
-  const originalMathRandom = Math.random;
-
   // The read emoji randomly rotates, but then the snapshots would never match
   // Have to make it consistent so the emojis are always the same
   beforeEach(() => {
     global.Math.random = jest.fn(() => 0.1);
   });
 
-  afterEach(() => {
-    global.Math.random = originalMathRandom;
-  });
-
   it('should render itself & its children', () => {
     const tree = render(<AllRead />);
 
diff --git a/src/components/RepositoryNotifications.test.tsx b/src/components/RepositoryNotifications.test.tsx
index 7f1024d9..1e67b7ee 100644
--- a/src/components/RepositoryNotifications.test.tsx
+++ b/src/components/RepositoryNotifications.test.tsx
@@ -23,8 +23,8 @@ describe('components/Repository.tsx', () => {
     repoNotifications: mockGitHubNotifications,
   };
 
-  beforeEach(() => {
-    markRepoNotificationsRead.mockReset();
+  afterEach(() => {
+    jest.clearAllMocks();
   });
 
   it('should render itself & its children', () => {
diff --git a/src/components/Sidebar.test.tsx b/src/components/Sidebar.test.tsx
index 66ebbf24..0d2588e7 100644
--- a/src/components/Sidebar.test.tsx
+++ b/src/components/Sidebar.test.tsx
@@ -15,12 +15,7 @@ jest.mock('react-router-dom', () => ({
 
 describe('components/Sidebar.tsx', () => {
   const fetchNotifications = jest.fn();
-
-  beforeEach(() => {
-    fetchNotifications.mockReset();
-
-    jest.spyOn(window, 'clearInterval');
-  });
+  const openExternalLinkMock = jest.spyOn(comms, 'openExternalLink');
 
   afterEach(() => {
     jest.clearAllMocks();
@@ -39,6 +34,7 @@ describe('components/Sidebar.tsx', () => {
         </MemoryRouter>
       </AppContext.Provider>,
     );
+
     expect(tree).toMatchSnapshot();
   });
 
@@ -52,9 +48,127 @@ describe('components/Sidebar.tsx', () => {
         </MemoryRouter>
       </AppContext.Provider>,
     );
+
     expect(tree).toMatchSnapshot();
   });
 
+  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(openExternalLinkMock).toHaveBeenCalledTimes(1);
+    expect(openExternalLinkMock).toHaveBeenCalledWith(
+      'https://github.com/gitify-app/gitify',
+    );
+  });
+
+  describe('quick links', () => {
+    describe('notifications icon', () => {
+      it('when there are 0 notifications', () => {
+        render(
+          <AppContext.Provider value={{ isLoggedIn: true, notifications: [] }}>
+            <MemoryRouter>
+              <Sidebar />
+            </MemoryRouter>
+          </AppContext.Provider>,
+        );
+
+        const notificationsIcon = screen.getByTitle('0 Unread Notifications');
+
+        expect(notificationsIcon.className).toContain('text-white');
+        expect(notificationsIcon.childNodes.length).toBe(1);
+        expect(notificationsIcon.childNodes[0].nodeName).toBe('svg');
+
+        fireEvent.click(screen.getByLabelText('0 Unread Notifications'));
+
+        expect(openExternalLinkMock).toHaveBeenCalledTimes(1);
+        expect(openExternalLinkMock).toHaveBeenCalledWith(
+          'https://github.com/notifications',
+        );
+      });
+
+      it('when there are more than 0 notifications', () => {
+        render(
+          <AppContext.Provider
+            value={{
+              isLoggedIn: true,
+              notifications: mockAccountNotifications,
+            }}
+          >
+            <MemoryRouter>
+              <Sidebar />
+            </MemoryRouter>
+          </AppContext.Provider>,
+        );
+
+        const notificationsIcon = screen.getByTitle('4 Unread Notifications');
+
+        expect(notificationsIcon.className).toContain(IconColor.GREEN);
+        expect(notificationsIcon.childNodes.length).toBe(2);
+        expect(notificationsIcon.childNodes[0].nodeName).toBe('svg');
+        expect(notificationsIcon.childNodes[1].nodeValue).toBe('4');
+
+        fireEvent.click(screen.getByLabelText('4 Unread Notifications'));
+
+        expect(openExternalLinkMock).toHaveBeenCalledTimes(1);
+        expect(openExternalLinkMock).toHaveBeenCalledWith(
+          'https://github.com/notifications',
+        );
+      });
+    });
+  });
+
+  it('opens my github issues page', () => {
+    render(
+      <AppContext.Provider
+        value={{
+          isLoggedIn: true,
+          notifications: mockAccountNotifications,
+        }}
+      >
+        <MemoryRouter>
+          <Sidebar />
+        </MemoryRouter>
+      </AppContext.Provider>,
+    );
+
+    fireEvent.click(screen.getByLabelText('My Issues'));
+
+    expect(openExternalLinkMock).toHaveBeenCalledTimes(1);
+    expect(openExternalLinkMock).toHaveBeenCalledWith(
+      'https://github.com/issues',
+    );
+  });
+
+  it('opens my github pull requests page', () => {
+    render(
+      <AppContext.Provider
+        value={{
+          isLoggedIn: true,
+          notifications: mockAccountNotifications,
+        }}
+      >
+        <MemoryRouter>
+          <Sidebar />
+        </MemoryRouter>
+      </AppContext.Provider>,
+    );
+
+    fireEvent.click(screen.getByLabelText('My Pull Requests'));
+
+    expect(openExternalLinkMock).toHaveBeenCalledTimes(1);
+    expect(openExternalLinkMock).toHaveBeenCalledWith(
+      'https://github.com/pulls',
+    );
+  });
+
   describe('Refresh Notifications', () => {
     it('should refresh the notifications when status is not loading', () => {
       render(
@@ -71,7 +185,7 @@ describe('components/Sidebar.tsx', () => {
           </MemoryRouter>
         </AppContext.Provider>,
       );
-      fetchNotifications.mockReset();
+
       fireEvent.click(screen.getByTitle('Refresh Notifications'));
 
       expect(fetchNotifications).toHaveBeenCalledTimes(1);
@@ -92,7 +206,7 @@ describe('components/Sidebar.tsx', () => {
           </MemoryRouter>
         </AppContext.Provider>,
       );
-      fetchNotifications.mockReset();
+
       fireEvent.click(screen.getByTitle('Refresh Notifications'));
 
       expect(fetchNotifications).not.toHaveBeenCalled();
@@ -108,7 +222,9 @@ describe('components/Sidebar.tsx', () => {
           </MemoryRouter>
         </AppContext.Provider>,
       );
+
       fireEvent.click(screen.getByTitle('Settings'));
+
       expect(mockNavigate).toHaveBeenCalledWith('/settings');
     });
 
@@ -120,77 +236,13 @@ describe('components/Sidebar.tsx', () => {
           </MemoryRouter>
         </AppContext.Provider>,
       );
+
       fireEvent.click(screen.getByTitle('Settings'));
+
       expect(mockNavigate).toHaveBeenCalledWith('/', { replace: true });
     });
   });
 
-  it('opens github in the notifications page', () => {
-    const openExternalLinkMock = jest.spyOn(comms, 'openExternalLink');
-
-    render(
-      <AppContext.Provider
-        value={{
-          isLoggedIn: true,
-          notifications: mockAccountNotifications,
-        }}
-      >
-        <MemoryRouter>
-          <Sidebar />
-        </MemoryRouter>
-      </AppContext.Provider>,
-    );
-    fireEvent.click(screen.getByLabelText('4 Unread Notifications'));
-    expect(openExternalLinkMock).toHaveBeenCalledTimes(1);
-    expect(openExternalLinkMock).toHaveBeenCalledWith(
-      'https://github.com/notifications',
-    );
-  });
-
-  it('opens my github issues page', () => {
-    const openExternalLinkMock = jest.spyOn(comms, 'openExternalLink');
-
-    render(
-      <AppContext.Provider
-        value={{
-          isLoggedIn: true,
-          notifications: mockAccountNotifications,
-        }}
-      >
-        <MemoryRouter>
-          <Sidebar />
-        </MemoryRouter>
-      </AppContext.Provider>,
-    );
-    fireEvent.click(screen.getByLabelText('My Issues'));
-    expect(openExternalLinkMock).toHaveBeenCalledTimes(1);
-    expect(openExternalLinkMock).toHaveBeenCalledWith(
-      'https://github.com/issues',
-    );
-  });
-
-  it('opens my github pull requests page', () => {
-    const openExternalLinkMock = jest.spyOn(comms, 'openExternalLink');
-
-    render(
-      <AppContext.Provider
-        value={{
-          isLoggedIn: true,
-          notifications: mockAccountNotifications,
-        }}
-      >
-        <MemoryRouter>
-          <Sidebar />
-        </MemoryRouter>
-      </AppContext.Provider>,
-    );
-    fireEvent.click(screen.getByLabelText('My Pull Requests'));
-    expect(openExternalLinkMock).toHaveBeenCalledTimes(1);
-    expect(openExternalLinkMock).toHaveBeenCalledWith(
-      'https://github.com/pulls',
-    );
-  });
-
   it('should quit the app', () => {
     const quitAppMock = jest.spyOn(comms, 'quitApp');
 
@@ -201,62 +253,9 @@ describe('components/Sidebar.tsx', () => {
         </MemoryRouter>
       </AppContext.Provider>,
     );
-    fireEvent.click(screen.getByTitle('Quit Gitify'));
-    expect(quitAppMock).toHaveBeenCalledTimes(1);
-  });
-
-  it('should open the gitify repository', () => {
-    const openExternalLinkMock = jest.spyOn(comms, 'openExternalLink');
-
-    render(
-      <AppContext.Provider value={{ isLoggedIn: false, notifications: [] }}>
-        <MemoryRouter>
-          <Sidebar />
-        </MemoryRouter>
-      </AppContext.Provider>,
-    );
-    fireEvent.click(screen.getByTestId('gitify-logo'));
-    expect(openExternalLinkMock).toHaveBeenCalledTimes(1);
-    expect(openExternalLinkMock).toHaveBeenCalledWith(
-      'https://github.com/gitify-app/gitify',
-    );
-  });
-
-  describe('should render the notifications icon', () => {
-    it('when there are 0 notifications', () => {
-      render(
-        <AppContext.Provider value={{ isLoggedIn: true, notifications: [] }}>
-          <MemoryRouter>
-            <Sidebar />
-          </MemoryRouter>
-        </AppContext.Provider>,
-      );
-
-      const notificationsIcon = screen.getByTitle('0 Unread Notifications');
-      expect(notificationsIcon.className).toContain('text-white');
-      expect(notificationsIcon.childNodes.length).toBe(1);
-      expect(notificationsIcon.childNodes[0].nodeName).toBe('svg');
-    });
 
-    it('when there are more than 0 notifications', () => {
-      render(
-        <AppContext.Provider
-          value={{
-            isLoggedIn: true,
-            notifications: mockAccountNotifications,
-          }}
-        >
-          <MemoryRouter>
-            <Sidebar />
-          </MemoryRouter>
-        </AppContext.Provider>,
-      );
+    fireEvent.click(screen.getByTitle('Quit Gitify'));
 
-      const notificationsIcon = screen.getByTitle('4 Unread Notifications');
-      expect(notificationsIcon.className).toContain(IconColor.GREEN);
-      expect(notificationsIcon.childNodes.length).toBe(2);
-      expect(notificationsIcon.childNodes[0].nodeName).toBe('svg');
-      expect(notificationsIcon.childNodes[1].nodeValue).toBe('4');
-    });
+    expect(quitAppMock).toHaveBeenCalledTimes(1);
   });
 });
diff --git a/src/components/buttons/Button.test.tsx b/src/components/buttons/Button.test.tsx
index 54b2e382..b4fb3d49 100644
--- a/src/components/buttons/Button.test.tsx
+++ b/src/components/buttons/Button.test.tsx
@@ -13,8 +13,8 @@ describe('components/buttons/Button.tsx', () => {
     size: Size.MEDIUM,
   };
 
-  beforeEach(() => {
-    openExternalMock.mockReset();
+  afterEach(() => {
+    jest.clearAllMocks();
   });
 
   it('should render without icon', () => {
diff --git a/src/context/App.test.tsx b/src/context/App.test.tsx
index d68d37ff..bc0e2d67 100644
--- a/src/context/App.test.tsx
+++ b/src/context/App.test.tsx
@@ -65,6 +65,10 @@ describe('context/App.tsx', () => {
       });
     });
 
+    afterEach(() => {
+      jest.clearAllMocks();
+    });
+
     it('fetch notifications every minute', async () => {
       customRender(null);
 
@@ -74,25 +78,23 @@ describe('context/App.tsx', () => {
         expect(fetchNotificationsMock).toHaveBeenCalledTimes(1),
       );
 
-      fetchNotificationsMock.mockReset();
-
       act(() => {
         jest.advanceTimersByTime(Constants.FETCH_INTERVAL);
         return;
       });
-      expect(fetchNotificationsMock).toHaveBeenCalledTimes(1);
+      expect(fetchNotificationsMock).toHaveBeenCalledTimes(2);
 
       act(() => {
         jest.advanceTimersByTime(Constants.FETCH_INTERVAL);
         return;
       });
-      expect(fetchNotificationsMock).toHaveBeenCalledTimes(2);
+      expect(fetchNotificationsMock).toHaveBeenCalledTimes(3);
 
       act(() => {
         jest.advanceTimersByTime(Constants.FETCH_INTERVAL);
         return;
       });
-      expect(fetchNotificationsMock).toHaveBeenCalledTimes(3);
+      expect(fetchNotificationsMock).toHaveBeenCalledTimes(4);
     });
 
     it('should call fetchNotifications', async () => {
@@ -131,8 +133,6 @@ describe('context/App.tsx', () => {
 
       const { getByText } = customRender(<TestComponent />);
 
-      markNotificationReadMock.mockReset();
-
       fireEvent.click(getByText('Test Case'));
 
       expect(markNotificationReadMock).toHaveBeenCalledTimes(1);
@@ -158,8 +158,6 @@ describe('context/App.tsx', () => {
 
       const { getByText } = customRender(<TestComponent />);
 
-      markNotificationDoneMock.mockReset();
-
       fireEvent.click(getByText('Test Case'));
 
       expect(markNotificationDoneMock).toHaveBeenCalledTimes(1);
@@ -185,8 +183,6 @@ describe('context/App.tsx', () => {
 
       const { getByText } = customRender(<TestComponent />);
 
-      unsubscribeNotificationMock.mockReset();
-
       fireEvent.click(getByText('Test Case'));
 
       expect(unsubscribeNotificationMock).toHaveBeenCalledTimes(1);
@@ -212,8 +208,6 @@ describe('context/App.tsx', () => {
 
       const { getByText } = customRender(<TestComponent />);
 
-      markRepoNotificationsReadMock.mockReset();
-
       fireEvent.click(getByText('Test Case'));
 
       expect(markRepoNotificationsReadMock).toHaveBeenCalledTimes(1);
@@ -239,8 +233,6 @@ describe('context/App.tsx', () => {
 
       const { getByText } = customRender(<TestComponent />);
 
-      markRepoNotificationsDoneMock.mockReset();
-
       fireEvent.click(getByText('Test Case'));
 
       expect(markRepoNotificationsDoneMock).toHaveBeenCalledTimes(1);
diff --git a/src/routes/Accounts.test.tsx b/src/routes/Accounts.test.tsx
index dc9e3b92..573df05a 100644
--- a/src/routes/Accounts.test.tsx
+++ b/src/routes/Accounts.test.tsx
@@ -20,7 +20,7 @@ jest.mock('react-router-dom', () => ({
 }));
 
 describe('routes/Accounts.tsx', () => {
-  beforeEach(() => {
+  afterEach(() => {
     jest.clearAllMocks();
   });
 
diff --git a/src/routes/Login.test.tsx b/src/routes/Login.test.tsx
index 8c985552..64e440a9 100644
--- a/src/routes/Login.test.tsx
+++ b/src/routes/Login.test.tsx
@@ -11,8 +11,8 @@ jest.mock('react-router-dom', () => ({
 }));
 
 describe('routes/Login.tsx', () => {
-  beforeEach(() => {
-    mockNavigate.mockReset();
+  afterEach(() => {
+    jest.clearAllMocks();
   });
 
   it('should render itself & its children', () => {
diff --git a/src/routes/LoginWithOAuthApp.test.tsx b/src/routes/LoginWithOAuthApp.test.tsx
index 01156267..4a4320ef 100644
--- a/src/routes/LoginWithOAuthApp.test.tsx
+++ b/src/routes/LoginWithOAuthApp.test.tsx
@@ -18,9 +18,8 @@ describe('routes/LoginWithOAuthApp.tsx', () => {
     accounts: [],
   };
 
-  beforeEach(() => {
-    openExternalMock.mockReset();
-    mockNavigate.mockReset();
+  afterEach(() => {
+    jest.clearAllMocks();
   });
 
   it('renders correctly', () => {
diff --git a/src/routes/LoginWithPersonalAccessToken.test.tsx b/src/routes/LoginWithPersonalAccessToken.test.tsx
index a6ea100c..83c9c284 100644
--- a/src/routes/LoginWithPersonalAccessToken.test.tsx
+++ b/src/routes/LoginWithPersonalAccessToken.test.tsx
@@ -24,10 +24,8 @@ describe('routes/LoginWithPersonalAccessToken.tsx', () => {
 
   const mockValidateToken = jest.fn();
 
-  beforeEach(() => {
-    mockValidateToken.mockReset();
-    openExternalMock.mockReset();
-    mockNavigate.mockReset();
+  afterEach(() => {
+    jest.clearAllMocks();
   });
 
   it('renders correctly', () => {
diff --git a/src/routes/Settings.test.tsx b/src/routes/Settings.test.tsx
index d6c2a2f2..67b876a8 100644
--- a/src/routes/Settings.test.tsx
+++ b/src/routes/Settings.test.tsx
@@ -22,7 +22,7 @@ describe('routes/Settings.tsx', () => {
     mockPlatform('darwin');
   });
 
-  beforeEach(() => {
+  afterEach(() => {
     jest.clearAllMocks();
   });
 
diff --git a/src/utils/api/client.test.ts b/src/utils/api/client.test.ts
index 7065150a..930ee9c0 100644
--- a/src/utils/api/client.test.ts
+++ b/src/utils/api/client.test.ts
@@ -26,7 +26,7 @@ const mockRepoSlug = 'gitify-app/notifications-test';
 
 describe('utils/api/client.ts', () => {
   afterEach(() => {
-    jest.resetAllMocks();
+    jest.clearAllMocks();
   });
 
   describe('getAuthenticatedUser', () => {
diff --git a/src/utils/api/request.test.ts b/src/utils/api/request.test.ts
index 6be72fb5..29937c58 100644
--- a/src/utils/api/request.test.ts
+++ b/src/utils/api/request.test.ts
@@ -9,7 +9,7 @@ const method = 'get';
 
 describe('utils/api/request.ts', () => {
   afterEach(() => {
-    jest.resetAllMocks();
+    jest.clearAllMocks();
   });
 
   it('should make a request with the correct parameters', async () => {
@@ -44,7 +44,7 @@ describe('apiRequestAuth', () => {
   const token = 'yourAuthToken' as Token;
 
   afterEach(() => {
-    jest.resetAllMocks();
+    jest.clearAllMocks();
   });
 
   it('should make an authenticated request with the correct parameters', async () => {
diff --git a/src/utils/auth/utils.test.ts b/src/utils/auth/utils.test.ts
index 9f839959..96c1ebf6 100644
--- a/src/utils/auth/utils.test.ts
+++ b/src/utils/auth/utils.test.ts
@@ -20,8 +20,8 @@ describe('utils/auth/utils.ts', () => {
   describe('authGitHub', () => {
     const loadURLMock = jest.spyOn(browserWindow, 'loadURL');
 
-    beforeEach(() => {
-      loadURLMock.mockReset();
+    afterEach(() => {
+      jest.clearAllMocks();
     });
 
     it('should call authGitHub - success', async () => {
@@ -47,7 +47,7 @@ describe('utils/auth/utils.ts', () => {
 
       expect(loadURLMock).toHaveBeenCalledTimes(1);
       expect(loadURLMock).toHaveBeenCalledWith(
-        'https://github.com/login/oauth/authorize?client_id=FAKE_CLIENT_ID_123&scope=read:user,notifications,repo',
+        'https://github.com/login/oauth/authorize?client_id=FAKE_CLIENT_ID_123&scope=read%3Auser%2Cnotifications%2Crepo',
       );
 
       expect(browserWindow.destroy).toHaveBeenCalledTimes(1);
diff --git a/src/utils/icons.test.ts b/src/utils/icons.test.ts
index 7f1f7747..9e991f51 100644
--- a/src/utils/icons.test.ts
+++ b/src/utils/icons.test.ts
@@ -263,6 +263,7 @@ describe('utils/icons.ts', () => {
   describe('getPullRequestReviewIcon', () => {
     let mockReviewSingleReviewer: GitifyPullRequestReview;
     let mockReviewMultipleReviewer: GitifyPullRequestReview;
+
     beforeEach(() => {
       mockReviewSingleReviewer = {
         state: 'APPROVED',
diff --git a/src/utils/subject.test.ts b/src/utils/subject.test.ts
index 9bd3a3af..5b030539 100644
--- a/src/utils/subject.test.ts
+++ b/src/utils/subject.test.ts
@@ -400,6 +400,7 @@ describe('utils/subject.ts', () => {
 
     describe('Issues', () => {
       let mockNotification: Notification;
+
       beforeEach(() => {
         mockNotification = partialMockNotification({
           title: 'This is a mock issue',