1- import { Constants } from '../constants' ;
21import type {
32 AccountNotifications ,
43 GitifyNotification ,
4+ GitifyNotificationUser ,
5+ GitifyOwner ,
56 GitifyReason ,
67 GitifyRepository ,
78 GitifySubject ,
8- Hostname ,
99 Link ,
1010} from '../types' ;
1111import {
12- mockEnterpriseNotifications ,
13- mockGitHubNotifications ,
14- mockSingleNotification ,
15- } from '../utils/api/__mocks__/response-mocks' ;
16- import {
12+ mockGitHubAppAccount ,
1713 mockGitHubCloudAccount ,
1814 mockGitHubEnterpriseServerAccount ,
1915} from './account-mocks' ;
20- import { mockToken } from './state-mocks' ;
21- import { mockGitifyUser } from './user-mocks' ;
2216
23- export const mockAccountNotifications : AccountNotifications [ ] = [
17+ const mockGitHubOwner : GitifyOwner = {
18+ login : 'gitify-app' ,
19+ avatarUrl :
20+ 'https://avatars.githubusercontent.com/u/133795385?s=200&v=4' as Link ,
21+ type : 'User' ,
22+ } ;
23+
24+ const mockGitHubRepository : GitifyRepository = {
25+ name : 'notifications-test' ,
26+ fullName : 'gitify-app/notifications-test' ,
27+ owner : mockGitHubOwner ,
28+ htmlUrl : 'https://github.com/gitify-app/notifications-test' as Link ,
29+ } ;
30+
31+ const mockSubjectUser : GitifyNotificationUser = {
32+ login : 'gitify-app' ,
33+ htmlUrl : 'https://github.com/gitify-app' as Link ,
34+ avatarUrl :
35+ 'https://avatars.githubusercontent.com/u/133795385?s=200&v=4' as Link ,
36+ type : 'User' ,
37+ } ;
38+
39+ /**
40+ * Mock Gitify Notifications for GitHub Cloud account
41+ *
42+ * 2 Notifications
43+ * Hostname: 'github.com'
44+ * Repository: 'gitify-app/notifications-test'
45+ */
46+ export const mockGitHubCloudGitifyNotifications : GitifyNotification [ ] = [
2447 {
2548 account : mockGitHubCloudAccount ,
26- notifications : mockGitHubNotifications ,
49+ order : 0 ,
50+ id : '138661096' ,
51+ unread : true ,
52+ reason : {
53+ code : 'subscribed' ,
54+ title : 'Updated' ,
55+ description : "You're watching the repository." ,
56+ } ,
57+ updatedAt : '2017-05-20T17:51:57Z' ,
58+ subject : {
59+ title : 'I am a robot and this is a test!' ,
60+ url : 'https://api.github.com/repos/gitify-app/notifications-test/issues/1' as Link ,
61+ latestCommentUrl :
62+ 'https://api.github.com/repos/gitify-app/notifications-test/issues/comments/302888448' as Link ,
63+ type : 'Issue' ,
64+ state : 'OPEN' ,
65+ user : mockSubjectUser ,
66+ reviews : [
67+ {
68+ state : 'APPROVED' ,
69+ users : [ 'octocat' ] ,
70+ } ,
71+ {
72+ state : 'CHANGES_REQUESTED' ,
73+ users : [ 'gitify-app' ] ,
74+ } ,
75+ {
76+ state : 'PENDING' ,
77+ users : [ 'gitify-user' ] ,
78+ } ,
79+ ] ,
80+ } ,
81+ repository : mockGitHubRepository ,
82+ } ,
83+ {
84+ account : mockGitHubCloudAccount ,
85+ order : 1 ,
86+ id : '148827438' ,
87+ unread : true ,
88+ reason : {
89+ code : 'author' ,
90+ title : 'Authored' ,
91+ description : 'You created the thread.' ,
92+ } ,
93+ updatedAt : '2017-05-20T17:06:34Z' ,
94+ subject : {
95+ title : 'Improve the UI' ,
96+ url : 'https://api.github.com/repos/gitify-app/notifications-test/issues/4' as Link ,
97+ latestCommentUrl :
98+ 'https://api.github.com/repos/gitify-app/notifications-test/issues/comments/302885965' as Link ,
99+ type : 'Issue' ,
100+ reviews : null ,
101+ } ,
102+ repository : mockGitHubRepository ,
103+ } ,
104+ ] ;
105+
106+ const mockEnterpriseOwner : GitifyOwner = {
107+ login : 'myorg' ,
108+ avatarUrl : 'https://github.gitify.io/avatars/u/4?' as Link ,
109+ type : 'Organization' ,
110+ } ;
111+
112+ const mockEnterpriseRepository : GitifyRepository = {
113+ name : 'notifications-test' ,
114+ fullName : 'myorg/notifications-test' ,
115+ owner : mockEnterpriseOwner ,
116+ htmlUrl : 'https://github.gitify.io/myorg/notifications-test' as Link ,
117+ } ;
118+
119+ /**
120+ * Mock Gitify Notifications for GitHub Enterprise account
121+ *
122+ * 2 Notifications
123+ * Hostname: 'github.gitify.io'
124+ * Repository: 'myorg/notifications-test'
125+ */
126+ export const mockGithubEnterpriseGitifyNotifications : GitifyNotification [ ] = [
127+ {
128+ account : mockGitHubEnterpriseServerAccount ,
129+ order : 0 ,
130+ id : '3' ,
131+ unread : true ,
132+ reason : {
133+ code : 'subscribed' ,
134+ title : 'Updated' ,
135+ description : "You're watching the repository." ,
136+ } ,
137+ updatedAt : '2017-05-20T13:02:48Z' ,
138+ subject : {
139+ title : 'Release 0.0.1' ,
140+ url : 'https://github.gitify.io/api/v3/repos/myorg/notifications-test/releases/3' as Link ,
141+ latestCommentUrl :
142+ 'https://github.gitify.io/api/v3/repos/myorg/notifications-test/releases/3' as Link ,
143+ type : 'Release' ,
144+ reviews : null ,
145+ } ,
146+ repository : mockEnterpriseRepository ,
147+ } ,
148+ {
149+ account : mockGitHubEnterpriseServerAccount ,
150+ order : 1 ,
151+ id : '4' ,
152+ unread : true ,
153+ reason : {
154+ code : 'subscribed' ,
155+ title : 'Updated' ,
156+ description : "You're watching the repository." ,
157+ } ,
158+ updatedAt : '2017-05-20T15:52:20Z' ,
159+ subject : {
160+ title : 'Bump Version' ,
161+ url : 'https://github.gitify.io/api/v3/repos/myorg/notifications-test/pulls/4' as Link ,
162+ latestCommentUrl :
163+ 'https://github.gitify.io/api/v3/repos/myorg/notifications-test/issues/comments/21' as Link ,
164+ type : 'PullRequest' ,
165+ reviews : null ,
166+ } ,
167+ repository : mockEnterpriseRepository ,
168+ } ,
169+ ] ;
170+
171+ export const mockGitifyNotification : GitifyNotification =
172+ mockGitHubCloudGitifyNotifications [ 0 ] ;
173+
174+ export const mockMultipleAccountNotifications : AccountNotifications [ ] = [
175+ {
176+ account : mockGitHubCloudAccount ,
177+ notifications : mockGitHubCloudGitifyNotifications ,
27178 error : null ,
28179 } ,
29180 {
30181 account : mockGitHubEnterpriseServerAccount ,
31- notifications : mockEnterpriseNotifications ,
182+ notifications : mockGithubEnterpriseGitifyNotifications ,
32183 error : null ,
33184 } ,
34185] ;
35186
36187export const mockSingleAccountNotifications : AccountNotifications [ ] = [
37188 {
38189 account : mockGitHubCloudAccount ,
39- notifications : [ mockSingleNotification ] ,
190+ notifications : [ mockGitifyNotification ] ,
40191 error : null ,
41192 } ,
42193] ;
43194
44- export function createPartialMockNotification (
195+ export function mockPartialGitifyNotification (
45196 subject : Partial < GitifySubject > ,
46197 repository ?: Partial < GitifyRepository > ,
47198) : GitifyNotification {
48199 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- } ,
200+ account : mockGitHubAppAccount ,
57201 reason : {
58202 code : 'subscribed' ,
59203 title : 'Updated' ,
60204 description : "You're watching the repository." ,
61205 } as GitifyReason ,
206+ updatedAt : '2026-01-01T17:00:00Z' ,
62207 subject : subject as GitifySubject ,
63208 repository : {
64209 name : 'notifications-test' ,
@@ -76,7 +221,7 @@ export function createPartialMockNotification(
76221 return mockNotification as GitifyNotification ;
77222}
78223
79- export function createMockNotificationForRepoName (
224+ export function mockGitifyNotificationForRepoName (
80225 id : string ,
81226 repoFullName : string | null ,
82227) : GitifyNotification {
0 commit comments