Skip to content

Commit 102c934

Browse files
authored
test: add notification color coverage (#790)
1 parent 2f92596 commit 102c934

File tree

4 files changed

+48
-9
lines changed

4 files changed

+48
-9
lines changed

src/typesGithub.ts

+3
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ export type IssueStateType =
2828
| 'completed'
2929
| 'reopened'
3030
| 'not_planned';
31+
3132
export type PullRequestStateType = 'closed' | 'open' | 'merged' | 'draft';
33+
3234
export type StateType = IssueStateType | PullRequestStateType;
35+
3336
export type ViewerSubscription = 'IGNORED' | 'SUBSCRIBED' | 'UNSUBSCRIBED';
3437

3538
export interface Notification {

src/utils/__snapshots__/github-api.test.ts.snap

+21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`./utils/github-api.ts should format the notification color 1`] = `"text-red-500"`;
4+
5+
exports[`./utils/github-api.ts should format the notification color 2`] = `"text-purple-500"`;
6+
7+
exports[`./utils/github-api.ts should format the notification color 3`] = `"text-gray-600"`;
8+
9+
exports[`./utils/github-api.ts should format the notification color 4`] = `"text-purple-500"`;
10+
11+
exports[`./utils/github-api.ts should format the notification color 5`] = `"text-gray-300"`;
12+
13+
exports[`./utils/github-api.ts should format the notification color 6`] = `"text-green-500"`;
14+
15+
exports[`./utils/github-api.ts should format the notification color 7`] = `"text-green-500"`;
16+
17+
exports[`./utils/github-api.ts should format the notification color 8`] = `
18+
{
19+
"description": "The reason for this notification is not supported by the app.",
20+
"type": "Unknown",
21+
}
22+
`;
23+
324
exports[`./utils/github-api.ts should format the notification reason 1`] = `
425
{
526
"description": "You were assigned to the issue.",

src/utils/github-api.test.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { formatReason, getNotificationTypeIcon } from './github-api';
1+
import {
2+
formatReason,
3+
getNotificationTypeIcon,
4+
getNotificationTypeIconColor,
5+
} from './github-api';
26
import { Reason, SubjectType } from '../typesGithub';
37

48
describe('./utils/github-api.ts', () => {
@@ -62,4 +66,15 @@ describe('./utils/github-api.ts', () => {
6266
'QuestionIcon',
6367
);
6468
});
69+
70+
it('should format the notification color', () => {
71+
expect(getNotificationTypeIconColor('closed')).toMatchSnapshot();
72+
expect(getNotificationTypeIconColor('completed')).toMatchSnapshot();
73+
expect(getNotificationTypeIconColor('draft')).toMatchSnapshot();
74+
expect(getNotificationTypeIconColor('merged')).toMatchSnapshot();
75+
expect(getNotificationTypeIconColor('not_planned')).toMatchSnapshot();
76+
expect(getNotificationTypeIconColor('open')).toMatchSnapshot();
77+
expect(getNotificationTypeIconColor('reopened')).toMatchSnapshot();
78+
expect(formatReason('something_else_unknown' as Reason)).toMatchSnapshot();
79+
});
6580
});

src/utils/github-api.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,18 @@ export function getNotificationTypeIconColor(state: StateType): string {
119119
switch (state) {
120120
case 'closed':
121121
return 'text-red-500';
122-
case 'open':
123-
return 'text-green-500';
124-
case 'merged':
125-
return 'text-purple-500';
126-
case 'reopened':
127-
return 'text-green-500';
128-
case 'not_planned':
129-
return 'text-gray-300';
130122
case 'completed':
131123
return 'text-purple-500';
132124
case 'draft':
133125
return 'text-gray-600';
126+
case 'merged':
127+
return 'text-purple-500';
128+
case 'not_planned':
129+
return 'text-gray-300';
130+
case 'open':
131+
return 'text-green-500';
132+
case 'reopened':
133+
return 'text-green-500';
134134
default:
135135
return 'text-gray-300';
136136
}

0 commit comments

Comments
 (0)