Skip to content

Commit 15523cd

Browse files
authored
chore: improve tests for sidebar (#590)
1 parent 710d9ac commit 15523cd

File tree

5 files changed

+35
-3
lines changed

5 files changed

+35
-3
lines changed

src/components/Logo.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ const LIGHT_GRADIENT_END = '#FFFFFF';
1212
const DARK_GRADIENT_START = '#22283B';
1313
const DARK_GRADIENT_END = '#555B6E';
1414

15-
export const Logo = ({ isDark, onClick, className = '' }: IProps) => (
15+
export const Logo = ({ isDark, onClick, className = '', ...props }: IProps) => (
1616
<svg
1717
className={className}
1818
onClick={() => onClick && onClick()}
1919
xmlns="http://www.w3.org/2000/svg"
2020
xmlnsXlink="http://www.w3.org/1999/xlink"
2121
viewBox="0 0 500 500"
2222
role="logo"
23+
{...props}
2324
>
2425
<defs>
2526
<linearGradient

src/components/Sidebar.test.tsx

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fireEvent, render } from '@testing-library/react';
1+
import { fireEvent, render, screen } from '@testing-library/react';
22
import { createMemoryHistory } from 'history';
33
import * as React from 'react';
44
import { Router } from 'react-router';
@@ -102,6 +102,34 @@ describe('components/Sidebar.tsx', () => {
102102
);
103103
});
104104

105+
it('should quit the app', () => {
106+
const { getByLabelText } = render(
107+
<AppContext.Provider value={{ isLoggedIn: false, notifications: [] }}>
108+
<MemoryRouter>
109+
<Sidebar />
110+
</MemoryRouter>
111+
</AppContext.Provider>
112+
);
113+
fireEvent.click(getByLabelText('Quit App'));
114+
expect(ipcRenderer.send).toHaveBeenCalledTimes(1);
115+
expect(ipcRenderer.send).toHaveBeenCalledWith('app-quit');
116+
});
117+
118+
it('should open the gitify repository', () => {
119+
render(
120+
<AppContext.Provider value={{ isLoggedIn: false, notifications: [] }}>
121+
<MemoryRouter>
122+
<Sidebar />
123+
</MemoryRouter>
124+
</AppContext.Provider>
125+
);
126+
fireEvent.click(screen.getByTestId('gitify-logo'));
127+
expect(shell.openExternal).toHaveBeenCalledTimes(1);
128+
expect(shell.openExternal).toHaveBeenCalledWith(
129+
'https://github.com/gitify-app/gitify'
130+
);
131+
});
132+
105133
describe('should render the notifications icon', () => {
106134
it('when there are 0 notifications', () => {
107135
const { getByLabelText } = render(

src/components/Sidebar.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const Sidebar: React.FC = () => {
4343
<div className="flex flex-col flex-1 items-center py-4">
4444
<Logo
4545
className="w-5 my-3 mx-auto cursor-pointer"
46+
data-testid="gitify-logo"
4647
onClick={onOpenBrowser}
4748
/>
4849

src/components/__snapshots__/Sidebar.test.tsx.snap

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ exports[`components/Sidebar.tsx should render itself & its children (logged in)
99
>
1010
<svg
1111
className="w-5 my-3 mx-auto cursor-pointer"
12+
data-testid="gitify-logo"
1213
onClick={[Function]}
1314
role="logo"
1415
viewBox="0 0 500 500"
@@ -127,6 +128,7 @@ exports[`components/Sidebar.tsx should render itself & its children (logged out)
127128
>
128129
<svg
129130
className="w-5 my-3 mx-auto cursor-pointer"
131+
data-testid="gitify-logo"
130132
onClick={[Function]}
131133
role="logo"
132134
viewBox="0 0 500 500"

src/utils/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const Constants = {
88
clientSecret: process.env.OAUTH_CLIENT_SECRET,
99
},
1010

11-
REPO_SLUG: 'manosim/gitify',
11+
REPO_SLUG: 'gitify-app/gitify',
1212

1313
// Storage
1414
STORAGE_KEY: 'gitify-storage',

0 commit comments

Comments
 (0)