Skip to content

Commit 49b4f6f

Browse files
committed
refactor: continued refactoring of test suite
Signed-off-by: Adam Setch <[email protected]>
1 parent 34f0ca6 commit 49b4f6f

File tree

8 files changed

+330
-148
lines changed

8 files changed

+330
-148
lines changed

src/renderer/__helpers__/test-utils.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export function AppContextProvider({
2626
return {
2727
auth: mockAuth,
2828
settings: mockSettings,
29+
isLoggedIn: true,
2930

3031
notifications: [],
3132

src/renderer/components/Sidebar.test.tsx

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { MemoryRouter } from 'react-router-dom';
44

55
import { renderWithAppContext } from '../__helpers__/test-utils';
66
import { mockAccountNotifications } from '../__mocks__/notifications-mocks';
7+
import { mockSettings } from '../__mocks__/state-mocks';
78
import * as comms from '../utils/comms';
89
import { Sidebar } from './Sidebar';
910

@@ -49,14 +50,11 @@ describe('renderer/components/Sidebar.tsx', () => {
4950
expect(tree).toMatchSnapshot();
5051
});
5152

52-
it('should navigate home when clicking the gitify logo', async () => {
53+
it('should navigate home when clicking logo', async () => {
5354
renderWithAppContext(
5455
<MemoryRouter>
5556
<Sidebar />
5657
</MemoryRouter>,
57-
{
58-
isLoggedIn: false,
59-
},
6058
);
6159

6260
await userEvent.click(screen.getByTestId('sidebar-home'));
@@ -71,9 +69,6 @@ describe('renderer/components/Sidebar.tsx', () => {
7169
<MemoryRouter>
7270
<Sidebar />
7371
</MemoryRouter>,
74-
{
75-
isLoggedIn: true,
76-
},
7772
);
7873

7974
await userEvent.click(screen.getByTestId('sidebar-notifications'));
@@ -90,7 +85,6 @@ describe('renderer/components/Sidebar.tsx', () => {
9085
<Sidebar />
9186
</MemoryRouter>,
9287
{
93-
isLoggedIn: true,
9488
notifications: [],
9589
},
9690
);
@@ -104,7 +98,6 @@ describe('renderer/components/Sidebar.tsx', () => {
10498
<Sidebar />
10599
</MemoryRouter>,
106100
{
107-
isLoggedIn: true,
108101
notifications: mockAccountNotifications,
109102
},
110103
);
@@ -119,9 +112,6 @@ describe('renderer/components/Sidebar.tsx', () => {
119112
<MemoryRouter>
120113
<Sidebar />
121114
</MemoryRouter>,
122-
{
123-
isLoggedIn: true,
124-
},
125115
);
126116

127117
await userEvent.click(screen.getByTestId('sidebar-filter-notifications'));
@@ -135,16 +125,31 @@ describe('renderer/components/Sidebar.tsx', () => {
135125
<MemoryRouter initialEntries={['/filters']}>
136126
<Sidebar />
137127
</MemoryRouter>,
138-
{
139-
isLoggedIn: true,
140-
},
141128
);
142129

143130
await userEvent.click(screen.getByTestId('sidebar-filter-notifications'));
144131

145132
expect(mockNavigate).toHaveBeenCalledTimes(1);
146133
expect(mockNavigate).toHaveBeenCalledWith('/', { replace: true });
147134
});
135+
136+
it('highlight filters sidebar if any are saved', () => {
137+
renderWithAppContext(
138+
<MemoryRouter>
139+
<Sidebar />
140+
</MemoryRouter>,
141+
{
142+
settings: {
143+
...mockSettings,
144+
filterReasons: ['assign'],
145+
},
146+
},
147+
);
148+
149+
expect(
150+
screen.getByTestId('sidebar-filter-notifications'),
151+
).toMatchSnapshot();
152+
});
148153
});
149154

150155
describe('quick links', () => {
@@ -154,7 +159,6 @@ describe('renderer/components/Sidebar.tsx', () => {
154159
<Sidebar />
155160
</MemoryRouter>,
156161
{
157-
isLoggedIn: true,
158162
notifications: mockAccountNotifications,
159163
},
160164
);
@@ -173,7 +177,6 @@ describe('renderer/components/Sidebar.tsx', () => {
173177
<Sidebar />
174178
</MemoryRouter>,
175179
{
176-
isLoggedIn: true,
177180
notifications: mockAccountNotifications,
178181
},
179182
);
@@ -194,8 +197,6 @@ describe('renderer/components/Sidebar.tsx', () => {
194197
<Sidebar />
195198
</MemoryRouter>,
196199
{
197-
isLoggedIn: true,
198-
notifications: [],
199200
fetchNotifications: mockFetchNotifications,
200201
status: 'success',
201202
},
@@ -212,8 +213,6 @@ describe('renderer/components/Sidebar.tsx', () => {
212213
<Sidebar />
213214
</MemoryRouter>,
214215
{
215-
isLoggedIn: true,
216-
notifications: [],
217216
fetchNotifications: mockFetchNotifications,
218217
status: 'loading',
219218
},
@@ -231,9 +230,6 @@ describe('renderer/components/Sidebar.tsx', () => {
231230
<MemoryRouter>
232231
<Sidebar />
233232
</MemoryRouter>,
234-
{
235-
isLoggedIn: true,
236-
},
237233
);
238234

239235
await userEvent.click(screen.getByTestId('sidebar-settings'));
@@ -248,7 +244,6 @@ describe('renderer/components/Sidebar.tsx', () => {
248244
<Sidebar />
249245
</MemoryRouter>,
250246
{
251-
isLoggedIn: true,
252247
fetchNotifications: mockFetchNotifications,
253248
},
254249
);

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

Lines changed: 34 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/components/fields/Tooltip.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ describe('renderer/components/fields/Tooltip.tsx', () => {
1111
};
1212

1313
it('should render', () => {
14-
renderWithAppContext(<Tooltip {...props} />, {});
14+
renderWithAppContext(<Tooltip {...props} />);
1515

1616
expect(screen.getByTestId('tooltip-test')).toBeInTheDocument();
1717
});
1818

1919
it('should display on mouse enter / leave', async () => {
20-
renderWithAppContext(<Tooltip {...props} />, {});
20+
renderWithAppContext(<Tooltip {...props} />);
2121

2222
const tooltipElement = screen.getByTestId('tooltip-test');
2323

0 commit comments

Comments
 (0)