1- import { Constants } from '../constants' ;
2- import type {
3- AccountNotifications ,
4- GitifyNotification ,
5- GitifyReason ,
6- GitifyRepository ,
7- GitifySubject ,
8- Hostname ,
9- Link ,
10- } from '../types' ;
111import {
12- mockEnterpriseNotifications ,
13- mockGitHubNotifications ,
14- mockSingleNotification ,
15- } from '../utils/api/__mocks__/response-mocks' ;
2+ FeedPullRequestOpenIcon ,
3+ IssueOpenedIcon ,
4+ } from '@primer/octicons-react' ;
5+
6+ import {
7+ type AccountNotifications ,
8+ type GitifyNotification ,
9+ type GitifyNotificationUser ,
10+ type GitifyOwner ,
11+ type GitifyReason ,
12+ type GitifyRepository ,
13+ type GitifySubject ,
14+ IconColor ,
15+ type Link ,
16+ } from '../types' ;
1617import {
18+ mockGitHubAppAccount ,
1719 mockGitHubCloudAccount ,
1820 mockGitHubEnterpriseServerAccount ,
1921} from './account-mocks' ;
20- import { mockToken } from './state-mocks' ;
21- import { mockGitifyUser } from './user-mocks' ;
2222
23- export const mockAccountNotifications : AccountNotifications [ ] = [
23+ const mockGitHubOwner : GitifyOwner = {
24+ login : 'gitify-app' ,
25+ avatarUrl :
26+ 'https://avatars.githubusercontent.com/u/133795385?s=200&v=4' as Link ,
27+ type : 'User' ,
28+ } ;
29+
30+ const mockGitHubRepository : GitifyRepository = {
31+ name : 'notifications-test' ,
32+ fullName : 'gitify-app/notifications-test' ,
33+ owner : mockGitHubOwner ,
34+ htmlUrl : 'https://github.com/gitify-app/notifications-test' as Link ,
35+ } ;
36+
37+ const mockSubjectUser : GitifyNotificationUser = {
38+ login : 'gitify-app' ,
39+ htmlUrl : 'https://github.com/gitify-app' as Link ,
40+ avatarUrl :
41+ 'https://avatars.githubusercontent.com/u/133795385?s=200&v=4' as Link ,
42+ type : 'User' ,
43+ } ;
44+
45+ /**
46+ * Mock Gitify Notifications for GitHub Cloud account
47+ *
48+ * 2 Notifications
49+ * Hostname: 'github.com'
50+ * Repository: 'gitify-app/notifications-test'
51+ */
52+ export const mockGitHubCloudGitifyNotifications : GitifyNotification [ ] = [
53+ {
54+ account : mockGitHubCloudAccount ,
55+ order : 0 ,
56+ id : '138661096' ,
57+ unread : true ,
58+ reason : {
59+ code : 'subscribed' ,
60+ title : 'Updated' ,
61+ description : "You're watching the repository." ,
62+ } ,
63+ updatedAt : '2017-05-20T17:51:57Z' ,
64+ subject : {
65+ title : 'I am a robot and this is a test!' ,
66+ url : 'https://api.github.com/repos/gitify-app/notifications-test/issues/1' as Link ,
67+ latestCommentUrl :
68+ 'https://api.github.com/repos/gitify-app/notifications-test/issues/comments/302888448' as Link ,
69+ type : 'Issue' ,
70+ state : 'OPEN' ,
71+ user : mockSubjectUser ,
72+ reviews : [
73+ {
74+ state : 'APPROVED' ,
75+ users : [ 'octocat' ] ,
76+ } ,
77+ {
78+ state : 'CHANGES_REQUESTED' ,
79+ users : [ 'gitify-app' ] ,
80+ } ,
81+ {
82+ state : 'PENDING' ,
83+ users : [ 'gitify-user' ] ,
84+ } ,
85+ ] ,
86+ } ,
87+ repository : mockGitHubRepository ,
88+ display : {
89+ number : '123' ,
90+ title : 'I am a robot and this is a test! [#123]' ,
91+ type : 'Open Issue' ,
92+ icon : {
93+ type : IssueOpenedIcon ,
94+ color : IconColor . GREEN ,
95+ } ,
96+ defaultUserType : 'User' ,
97+ } ,
98+ } ,
99+ {
100+ account : mockGitHubCloudAccount ,
101+ order : 1 ,
102+ id : '148827438' ,
103+ unread : true ,
104+ reason : {
105+ code : 'author' ,
106+ title : 'Authored' ,
107+ description : 'You created the thread.' ,
108+ } ,
109+ updatedAt : '2017-05-20T17:06:34Z' ,
110+ subject : {
111+ title : 'Improve the UI' ,
112+ url : 'https://api.github.com/repos/gitify-app/notifications-test/issues/4' as Link ,
113+ latestCommentUrl :
114+ 'https://api.github.com/repos/gitify-app/notifications-test/issues/comments/302885965' as Link ,
115+ type : 'Issue' ,
116+ reviews : null ,
117+ } ,
118+ repository : mockGitHubRepository ,
119+ display : {
120+ number : '456' ,
121+ title : 'Improve the UI [#456]' ,
122+ type : 'Issue' ,
123+ icon : {
124+ type : IssueOpenedIcon ,
125+ color : IconColor . GREEN ,
126+ } ,
127+ defaultUserType : 'User' ,
128+ } ,
129+ } ,
130+ ] ;
131+
132+ const mockEnterpriseOwner : GitifyOwner = {
133+ login : 'myorg' ,
134+ avatarUrl : 'https://github.gitify.io/avatars/u/4?' as Link ,
135+ type : 'Organization' ,
136+ } ;
137+
138+ const mockEnterpriseRepository : GitifyRepository = {
139+ name : 'notifications-test' ,
140+ fullName : 'myorg/notifications-test' ,
141+ owner : mockEnterpriseOwner ,
142+ htmlUrl : 'https://github.gitify.io/myorg/notifications-test' as Link ,
143+ } ;
144+
145+ /**
146+ * Mock Gitify Notifications for GitHub Enterprise account
147+ *
148+ * 2 Notifications
149+ * Hostname: 'github.gitify.io'
150+ * Repository: 'myorg/notifications-test'
151+ */
152+ export const mockGithubEnterpriseGitifyNotifications : GitifyNotification [ ] = [
153+ {
154+ account : mockGitHubEnterpriseServerAccount ,
155+ order : 0 ,
156+ id : '3' ,
157+ unread : true ,
158+ reason : {
159+ code : 'subscribed' ,
160+ title : 'Updated' ,
161+ description : "You're watching the repository." ,
162+ } ,
163+ updatedAt : '2017-05-20T13:02:48Z' ,
164+ subject : {
165+ title : 'Release 0.0.1' ,
166+ url : 'https://github.gitify.io/api/v3/repos/myorg/notifications-test/releases/3' as Link ,
167+ latestCommentUrl :
168+ 'https://github.gitify.io/api/v3/repos/myorg/notifications-test/releases/3' as Link ,
169+ type : 'Release' ,
170+ reviews : null ,
171+ } ,
172+ repository : mockEnterpriseRepository ,
173+ display : {
174+ number : '' ,
175+ title : 'Release 0.0.1' ,
176+ type : 'Release' ,
177+ icon : {
178+ type : IssueOpenedIcon ,
179+ color : IconColor . GREEN ,
180+ } ,
181+ defaultUserType : 'User' ,
182+ } ,
183+ } ,
184+ {
185+ account : mockGitHubEnterpriseServerAccount ,
186+ order : 1 ,
187+ id : '4' ,
188+ unread : true ,
189+ reason : {
190+ code : 'subscribed' ,
191+ title : 'Updated' ,
192+ description : "You're watching the repository." ,
193+ } ,
194+ updatedAt : '2017-05-20T15:52:20Z' ,
195+ subject : {
196+ title : 'Bump Version' ,
197+ url : 'https://github.gitify.io/api/v3/repos/myorg/notifications-test/pulls/4' as Link ,
198+ latestCommentUrl :
199+ 'https://github.gitify.io/api/v3/repos/myorg/notifications-test/issues/comments/21' as Link ,
200+ type : 'PullRequest' ,
201+ reviews : null ,
202+ } ,
203+ repository : mockEnterpriseRepository ,
204+ display : {
205+ number : '123' ,
206+ title : 'Bump Version [#123]' ,
207+ type : 'Pull Request' ,
208+ icon : {
209+ type : FeedPullRequestOpenIcon ,
210+ color : IconColor . GREEN ,
211+ } ,
212+ defaultUserType : 'User' ,
213+ } ,
214+ } ,
215+ ] ;
216+
217+ export const mockGitifyNotification : GitifyNotification =
218+ mockGitHubCloudGitifyNotifications [ 0 ] ;
219+
220+ export const mockMultipleAccountNotifications : AccountNotifications [ ] = [
24221 {
25222 account : mockGitHubCloudAccount ,
26- notifications : mockGitHubNotifications ,
223+ notifications : mockGitHubCloudGitifyNotifications ,
27224 error : null ,
28225 } ,
29226 {
30227 account : mockGitHubEnterpriseServerAccount ,
31- notifications : mockEnterpriseNotifications ,
228+ notifications : mockGithubEnterpriseGitifyNotifications ,
32229 error : null ,
33230 } ,
34231] ;
35232
36233export const mockSingleAccountNotifications : AccountNotifications [ ] = [
37234 {
38235 account : mockGitHubCloudAccount ,
39- notifications : [ mockSingleNotification ] ,
236+ notifications : [ mockGitifyNotification ] ,
40237 error : null ,
41238 } ,
42239] ;
43240
44- export function createPartialMockNotification (
241+ export function mockPartialGitifyNotification (
45242 subject : Partial < GitifySubject > ,
46243 repository ?: Partial < GitifyRepository > ,
47244) : GitifyNotification {
48245 const mockNotification : Partial < GitifyNotification > = {
49- account : {
50- method : 'Personal Access Token' ,
51- platform : 'GitHub Cloud' ,
52- hostname : Constants . GITHUB_API_BASE_URL as Hostname ,
53- token : mockToken ,
54- user : mockGitifyUser ,
55- hasRequiredScopes : true ,
56- } ,
246+ account : mockGitHubAppAccount ,
57247 reason : {
58248 code : 'subscribed' ,
59249 title : 'Updated' ,
60250 description : "You're watching the repository." ,
61251 } as GitifyReason ,
252+ updatedAt : '2026-01-01T17:00:00Z' ,
62253 subject : subject as GitifySubject ,
63254 repository : {
64255 name : 'notifications-test' ,
@@ -76,7 +267,7 @@ export function createPartialMockNotification(
76267 return mockNotification as GitifyNotification ;
77268}
78269
79- export function createMockNotificationForRepoName (
270+ export function mockGitifyNotificationForRepoName (
80271 id : string ,
81272 repoFullName : string | null ,
82273) : GitifyNotification {
0 commit comments