Skip to content

Commit 048be62

Browse files
authored
refactor: test prop interfaces and clarify animation state variables (#2552)
* refactor: prop types and animation state vars Signed-off-by: Adam Setch <adam.setch@outlook.com> * refactor: prop types and animation state vars Signed-off-by: Adam Setch <adam.setch@outlook.com> --------- Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent b9617e0 commit 048be62

13 files changed

Lines changed: 143 additions & 119 deletions

src/renderer/components/metrics/MetricGroup.test.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { mockSettings } from '../../__mocks__/state-mocks';
44

55
import type { GitifyMilestone } from '../../types';
66

7-
import { MetricGroup } from './MetricGroup';
7+
import { MetricGroup, type MetricGroupProps } from './MetricGroup';
88

99
describe('renderer/components/metrics/MetricGroup.tsx', () => {
1010
describe('showPills disabled', () => {
1111
it('should not render any pills when showPills is disabled', async () => {
1212
const mockNotification = mockGitifyNotification;
1313

14-
const props = {
14+
const props: MetricGroupProps = {
1515
notification: mockNotification,
1616
};
1717

@@ -27,7 +27,7 @@ describe('renderer/components/metrics/MetricGroup.tsx', () => {
2727
const mockNotification = mockGitifyNotification;
2828
mockNotification.subject.linkedIssues = ['#1'];
2929

30-
const props = {
30+
const props: MetricGroupProps = {
3131
notification: mockNotification,
3232
};
3333

@@ -39,7 +39,7 @@ describe('renderer/components/metrics/MetricGroup.tsx', () => {
3939
const mockNotification = mockGitifyNotification;
4040
mockNotification.subject.linkedIssues = ['#1', '#2'];
4141

42-
const props = {
42+
const props: MetricGroupProps = {
4343
notification: mockNotification,
4444
};
4545

@@ -53,7 +53,7 @@ describe('renderer/components/metrics/MetricGroup.tsx', () => {
5353
const mockNotification = mockGitifyNotification;
5454
mockNotification.subject.commentCount = null;
5555

56-
const props = {
56+
const props: MetricGroupProps = {
5757
notification: mockNotification,
5858
};
5959

@@ -65,7 +65,7 @@ describe('renderer/components/metrics/MetricGroup.tsx', () => {
6565
const mockNotification = mockGitifyNotification;
6666
mockNotification.subject.commentCount = 1;
6767

68-
const props = {
68+
const props: MetricGroupProps = {
6969
notification: mockNotification,
7070
};
7171

@@ -77,7 +77,7 @@ describe('renderer/components/metrics/MetricGroup.tsx', () => {
7777
const mockNotification = mockGitifyNotification;
7878
mockNotification.subject.commentCount = 2;
7979

80-
const props = {
80+
const props: MetricGroupProps = {
8181
notification: mockNotification,
8282
};
8383

@@ -91,7 +91,7 @@ describe('renderer/components/metrics/MetricGroup.tsx', () => {
9191
const mockNotification = mockGitifyNotification;
9292
mockNotification.subject.labels = ['enhancement', 'good-first-issue'];
9393

94-
const props = {
94+
const props: MetricGroupProps = {
9595
notification: mockNotification,
9696
};
9797

@@ -108,7 +108,7 @@ describe('renderer/components/metrics/MetricGroup.tsx', () => {
108108
state: 'OPEN',
109109
} as GitifyMilestone;
110110

111-
const props = {
111+
const props: MetricGroupProps = {
112112
notification: mockNotification,
113113
};
114114

@@ -123,7 +123,7 @@ describe('renderer/components/metrics/MetricGroup.tsx', () => {
123123
state: 'CLOSED',
124124
} as GitifyMilestone;
125125

126-
const props = {
126+
const props: MetricGroupProps = {
127127
notification: mockNotification,
128128
};
129129

src/renderer/components/metrics/MetricGroup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { type GitifyNotification, IconColor } from '../../types';
1414
import { getPullRequestReviewIcon } from '../../utils/icons';
1515
import { MetricPill } from './MetricPill';
1616

17-
interface MetricGroupProps {
17+
export interface MetricGroupProps {
1818
notification: GitifyNotification;
1919
}
2020

src/renderer/components/notifications/AccountNotifications.test.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import { mockSettings } from '../../__mocks__/state-mocks';
1212
import { GroupBy } from '../../types';
1313

1414
import * as links from '../../utils/links';
15-
import { AccountNotifications } from './AccountNotifications';
15+
import {
16+
AccountNotifications,
17+
type AccountNotificationsProps,
18+
} from './AccountNotifications';
1619

1720
jest.mock('./RepositoryNotifications', () => ({
1821
RepositoryNotifications: () => <div>RepositoryNotifications</div>,
@@ -24,7 +27,7 @@ describe('renderer/components/notifications/AccountNotifications.tsx', () => {
2427
});
2528

2629
it('should render itself - group notifications by repositories', () => {
27-
const props = {
30+
const props: AccountNotificationsProps = {
2831
account: mockGitHubCloudAccount,
2932
notifications: mockGitHubCloudGitifyNotifications,
3033
showAccountHeader: true,
@@ -39,7 +42,7 @@ describe('renderer/components/notifications/AccountNotifications.tsx', () => {
3942
});
4043

4144
it('should render itself - group notifications by date', () => {
42-
const props = {
45+
const props: AccountNotificationsProps = {
4346
account: mockGitHubCloudAccount,
4447
notifications: mockGitHubCloudGitifyNotifications,
4548
showAccountHeader: true,
@@ -54,7 +57,7 @@ describe('renderer/components/notifications/AccountNotifications.tsx', () => {
5457
});
5558

5659
it('should render itself - no notifications', async () => {
57-
const props = {
60+
const props: AccountNotificationsProps = {
5861
account: mockGitHubCloudAccount,
5962
notifications: [],
6063
showAccountHeader: true,
@@ -71,7 +74,7 @@ describe('renderer/components/notifications/AccountNotifications.tsx', () => {
7174
});
7275

7376
it('should render itself - account error for single account', async () => {
74-
const props = {
77+
const props: AccountNotificationsProps = {
7578
account: mockGitHubCloudAccount,
7679
notifications: [],
7780
error: {
@@ -94,7 +97,7 @@ describe('renderer/components/notifications/AccountNotifications.tsx', () => {
9497
});
9598

9699
it('should render itself - account error for multiple accounts', async () => {
97-
const props = {
100+
const props: AccountNotificationsProps = {
98101
account: mockGitHubCloudAccount,
99102
notifications: [],
100103
error: {
@@ -119,7 +122,7 @@ describe('renderer/components/notifications/AccountNotifications.tsx', () => {
119122
.spyOn(links, 'openAccountProfile')
120123
.mockImplementation();
121124

122-
const props = {
125+
const props: AccountNotificationsProps = {
123126
account: mockGitHubCloudAccount,
124127
notifications: [],
125128
showAccountHeader: true,
@@ -139,7 +142,7 @@ describe('renderer/components/notifications/AccountNotifications.tsx', () => {
139142
.spyOn(links, 'openGitHubIssues')
140143
.mockImplementation();
141144

142-
const props = {
145+
const props: AccountNotificationsProps = {
143146
account: mockGitHubCloudAccount,
144147
notifications: [],
145148
showAccountHeader: true,
@@ -161,7 +164,7 @@ describe('renderer/components/notifications/AccountNotifications.tsx', () => {
161164
.spyOn(links, 'openGitHubPulls')
162165
.mockImplementation();
163166

164-
const props = {
167+
const props: AccountNotificationsProps = {
165168
account: mockGitHubCloudAccount,
166169
notifications: [],
167170
showAccountHeader: true,
@@ -179,7 +182,7 @@ describe('renderer/components/notifications/AccountNotifications.tsx', () => {
179182
});
180183

181184
it('should toggle account notifications visibility', async () => {
182-
const props = {
185+
const props: AccountNotificationsProps = {
183186
account: mockGitHubCloudAccount,
184187
notifications: mockGitHubCloudGitifyNotifications,
185188
showAccountHeader: true,

src/renderer/components/notifications/AccountNotifications.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { Oops } from '../Oops';
3333
import { NotificationRow } from './NotificationRow';
3434
import { RepositoryNotifications } from './RepositoryNotifications';
3535

36-
interface AccountNotificationsProps {
36+
export interface AccountNotificationsProps {
3737
account: Account;
3838
notifications: GitifyNotification[];
3939
error: GitifyError | null;
@@ -150,6 +150,7 @@ export const AccountNotifications: FC<AccountNotificationsProps> = (
150150
))
151151
: sortedNotifications.map((notification) => (
152152
<NotificationRow
153+
isRepositoryAnimatingExit={false}
153154
key={notification.id}
154155
notification={notification}
155156
/>

src/renderer/components/notifications/NotificationFooter.test.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import { screen } from '@testing-library/react';
22
import userEvent from '@testing-library/user-event';
33

44
import { renderWithAppContext } from '../../__helpers__/test-utils';
5-
import { mockGitHubCloudAccount } from '../../__mocks__/account-mocks';
65
import { mockGitifyNotification } from '../../__mocks__/notifications-mocks';
76

87
import type { GitifyNotificationUser, Link } from '../../types';
98

109
import * as comms from '../../utils/comms';
11-
import { NotificationFooter } from './NotificationFooter';
10+
import {
11+
NotificationFooter,
12+
type NotificationFooterProps,
13+
} from './NotificationFooter';
1214

1315
describe('renderer/components/notifications/NotificationFooter.tsx', () => {
1416
jest
@@ -20,7 +22,7 @@ describe('renderer/components/notifications/NotificationFooter.tsx', () => {
2022
});
2123

2224
it('should render itself & its children', async () => {
23-
const props = {
25+
const props: NotificationFooterProps = {
2426
notification: mockGitifyNotification,
2527
};
2628

@@ -34,7 +36,7 @@ describe('renderer/components/notifications/NotificationFooter.tsx', () => {
3436
const mockNotification = mockGitifyNotification;
3537
mockNotification.subject.type = 'RepositoryDependabotAlertsThread';
3638

37-
const props = {
39+
const props: NotificationFooterProps = {
3840
notification: mockNotification,
3941
};
4042

@@ -47,7 +49,7 @@ describe('renderer/components/notifications/NotificationFooter.tsx', () => {
4749
const mockNotification = mockGitifyNotification;
4850
mockNotification.subject.type = 'RepositoryVulnerabilityAlert';
4951

50-
const props = {
52+
const props: NotificationFooterProps = {
5153
notification: mockNotification,
5254
};
5355

@@ -61,7 +63,7 @@ describe('renderer/components/notifications/NotificationFooter.tsx', () => {
6163
const mockNotification = mockGitifyNotification;
6264
mockNotification.subject.user = null;
6365

64-
const props = {
66+
const props: NotificationFooterProps = {
6567
notification: mockNotification,
6668
};
6769

@@ -75,7 +77,7 @@ describe('renderer/components/notifications/NotificationFooter.tsx', () => {
7577
.spyOn(comms, 'openExternalLink')
7678
.mockImplementation();
7779

78-
const props = {
80+
const props: NotificationFooterProps = {
7981
notification: {
8082
...mockGitifyNotification,
8183
subject: {
@@ -90,7 +92,6 @@ describe('renderer/components/notifications/NotificationFooter.tsx', () => {
9092
reviews: null,
9193
},
9294
},
93-
account: mockGitHubCloudAccount,
9495
};
9596

9697
renderWithAppContext(<NotificationFooter {...props} />);

src/renderer/components/notifications/NotificationFooter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { openUserProfile } from '../../utils/links';
99
import { AvatarWithFallback } from '../avatars/AvatarWithFallback';
1010
import { MetricGroup } from '../metrics/MetricGroup';
1111

12-
interface NotificationFooterProps {
12+
export interface NotificationFooterProps {
1313
notification: GitifyNotification;
1414
}
1515

src/renderer/components/notifications/NotificationHeader.test.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ import { mockSettings } from '../../__mocks__/state-mocks';
88
import { GroupBy } from '../../types';
99

1010
import * as comms from '../../utils/comms';
11-
import { NotificationHeader } from './NotificationHeader';
11+
import {
12+
NotificationHeader,
13+
type NotificationHeaderProps,
14+
} from './NotificationHeader';
1215

1316
describe('renderer/components/notifications/NotificationHeader.tsx', () => {
1417
afterEach(() => {
1518
jest.clearAllMocks();
1619
});
1720

1821
it('should render itself & its children - group by repositories', async () => {
19-
const props = {
22+
const props: NotificationHeaderProps = {
2023
notification: mockGitifyNotification,
2124
};
2225

@@ -29,7 +32,7 @@ describe('renderer/components/notifications/NotificationHeader.tsx', () => {
2932

3033
describe('should render itself & its children - group by date', () => {
3134
it('with notification number', async () => {
32-
const props = {
35+
const props: NotificationHeaderProps = {
3336
notification: mockGitifyNotification,
3437
};
3538

@@ -41,7 +44,7 @@ describe('renderer/components/notifications/NotificationHeader.tsx', () => {
4144
});
4245

4346
it('with showNumber setting disabled', async () => {
44-
const props = {
47+
const props: NotificationHeaderProps = {
4548
notification: mockGitifyNotification,
4649
};
4750

@@ -57,7 +60,7 @@ describe('renderer/components/notifications/NotificationHeader.tsx', () => {
5760
});
5861

5962
it('without notification number', async () => {
60-
const props = {
63+
const props: NotificationHeaderProps = {
6164
notification: {
6265
...mockGitifyNotification,
6366
subject: { ...mockGitifyNotification.subject, number: null },
@@ -77,7 +80,7 @@ describe('renderer/components/notifications/NotificationHeader.tsx', () => {
7780
.spyOn(comms, 'openExternalLink')
7881
.mockImplementation();
7982

80-
const props = {
83+
const props: NotificationHeaderProps = {
8184
notification: mockGitifyNotification,
8285
};
8386

src/renderer/components/notifications/NotificationHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { openRepository } from '../../utils/links';
1111
import { isGroupByDate } from '../../utils/notifications/group';
1212
import { AvatarWithFallback } from '../avatars/AvatarWithFallback';
1313

14-
interface NotificationHeaderProps {
14+
export interface NotificationHeaderProps {
1515
notification: GitifyNotification;
1616
}
1717

0 commit comments

Comments
 (0)