@@ -138,6 +138,65 @@ describe('utils/subject.ts', () => {
138138 } ) ;
139139
140140 describe ( 'getGitifySubjectDetails' , ( ) => {
141+ describe ( 'Commits' , ( ) => {
142+ it ( 'get commit commenter' , async ( ) => {
143+ const mockNotification = {
144+ ...mockedSingleNotification ,
145+ subject : {
146+ title : 'This is a commit with comments' ,
147+ url : 'https://api.github.com/repos/manosim/notifications-test/commits/d2a86d80e3d24ea9510d5de6c147e53c30f313a8' ,
148+ latest_comment_url :
149+ 'https://api.github.com/repos/manosim/notifications-test/comments/141012658' ,
150+ type : 'Commit' as SubjectType ,
151+ } ,
152+ } ;
153+
154+ nock ( 'https://api.github.com' )
155+ . get (
156+ '/repos/manosim/notifications-test/commits/d2a86d80e3d24ea9510d5de6c147e53c30f313a8' ,
157+ )
158+ . reply ( 200 , { author : { login : 'some-author' } } ) ;
159+
160+ nock ( 'https://api.github.com' )
161+ . get ( '/repos/manosim/notifications-test/comments/141012658' )
162+ . reply ( 200 , { user : { login : 'some-commenter' } } ) ;
163+
164+ const result = await getGitifySubjectDetails (
165+ mockNotification ,
166+ mockAccounts . token ,
167+ ) ;
168+
169+ expect ( result . state ) . toBeNull ( ) ;
170+ expect ( result . user ) . toEqual ( { login : 'some-commenter' } ) ;
171+ } ) ;
172+
173+ it ( 'get commit without commenter' , async ( ) => {
174+ const mockNotification = {
175+ ...mockedSingleNotification ,
176+ subject : {
177+ title : 'This is a commit with comments' ,
178+ url : 'https://api.github.com/repos/manosim/notifications-test/commits/d2a86d80e3d24ea9510d5de6c147e53c30f313a8' ,
179+ latest_comment_url : null ,
180+ type : 'Commit' as SubjectType ,
181+ } ,
182+ } ;
183+
184+ nock ( 'https://api.github.com' )
185+ . get (
186+ '/repos/manosim/notifications-test/commits/d2a86d80e3d24ea9510d5de6c147e53c30f313a8' ,
187+ )
188+ . reply ( 200 , { author : { login : 'some-author' } } ) ;
189+
190+ const result = await getGitifySubjectDetails (
191+ mockNotification ,
192+ mockAccounts . token ,
193+ ) ;
194+
195+ expect ( result . state ) . toBeNull ( ) ;
196+ expect ( result . user ) . toEqual ( { login : 'some-author' } ) ;
197+ } ) ;
198+ } ) ;
199+
141200 describe ( 'Discussions' , ( ) => {
142201 it ( 'answered discussion state' , async ( ) => {
143202 const mockNotification = {
0 commit comments