@@ -5,11 +5,10 @@ import { mockAccounts } from '../__mocks__/mock-state';
55import { mockedSingleNotification } from '../__mocks__/mockedData' ;
66import {
77 getCheckSuiteAttributes ,
8- getGitifySubjectForDiscussion ,
9- getGitifySubjectForIssue ,
10- getGitifySubjectForPullRequest ,
8+ getGitifySubjectDetails ,
119 getWorkflowRunAttributes ,
1210} from './subject' ;
11+ import { SubjectType } from '../typesGithub' ;
1312describe ( 'utils/state.ts' , ( ) => {
1413 beforeEach ( ( ) => {
1514 // axios will default to using the XHR adapter which can't be intercepted
@@ -142,6 +141,7 @@ describe('utils/state.ts', () => {
142141 subject : {
143142 ...mockedSingleNotification . subject ,
144143 title : 'This is an answered discussion' ,
144+ type : 'Discussion' as SubjectType ,
145145 } ,
146146 } ;
147147
@@ -165,7 +165,7 @@ describe('utils/state.ts', () => {
165165 } ,
166166 } ) ;
167167
168- const result = await getGitifySubjectForDiscussion (
168+ const result = await getGitifySubjectDetails (
169169 mockNotification ,
170170 mockAccounts . token ,
171171 ) ;
@@ -180,6 +180,7 @@ describe('utils/state.ts', () => {
180180 subject : {
181181 ...mockedSingleNotification . subject ,
182182 title : 'This is a duplicate discussion' ,
183+ type : 'Discussion' as SubjectType ,
183184 } ,
184185 } ;
185186
@@ -203,7 +204,7 @@ describe('utils/state.ts', () => {
203204 } ,
204205 } ) ;
205206
206- const result = await getGitifySubjectForDiscussion (
207+ const result = await getGitifySubjectDetails (
207208 mockNotification ,
208209 mockAccounts . token ,
209210 ) ;
@@ -218,6 +219,7 @@ describe('utils/state.ts', () => {
218219 subject : {
219220 ...mockedSingleNotification . subject ,
220221 title : 'This is an open discussion' ,
222+ type : 'Discussion' as SubjectType ,
221223 } ,
222224 } ;
223225
@@ -241,7 +243,7 @@ describe('utils/state.ts', () => {
241243 } ,
242244 } ) ;
243245
244- const result = await getGitifySubjectForDiscussion (
246+ const result = await getGitifySubjectDetails (
245247 mockNotification ,
246248 mockAccounts . token ,
247249 ) ;
@@ -256,6 +258,7 @@ describe('utils/state.ts', () => {
256258 subject : {
257259 ...mockedSingleNotification . subject ,
258260 title : 'This is an outdated discussion' ,
261+ type : 'Discussion' as SubjectType ,
259262 } ,
260263 } ;
261264
@@ -279,7 +282,7 @@ describe('utils/state.ts', () => {
279282 } ,
280283 } ) ;
281284
282- const result = await getGitifySubjectForDiscussion (
285+ const result = await getGitifySubjectDetails (
283286 mockNotification ,
284287 mockAccounts . token ,
285288 ) ;
@@ -294,6 +297,7 @@ describe('utils/state.ts', () => {
294297 subject : {
295298 ...mockedSingleNotification . subject ,
296299 title : 'This is a reopened discussion' ,
300+ type : 'Discussion' as SubjectType ,
297301 } ,
298302 } ;
299303
@@ -317,7 +321,7 @@ describe('utils/state.ts', () => {
317321 } ,
318322 } ) ;
319323
320- const result = await getGitifySubjectForDiscussion (
324+ const result = await getGitifySubjectDetails (
321325 mockNotification ,
322326 mockAccounts . token ,
323327 ) ;
@@ -332,6 +336,7 @@ describe('utils/state.ts', () => {
332336 subject : {
333337 ...mockedSingleNotification . subject ,
334338 title : 'This is a resolved discussion' ,
339+ type : 'Discussion' as SubjectType ,
335340 } ,
336341 } ;
337342
@@ -355,7 +360,7 @@ describe('utils/state.ts', () => {
355360 } ,
356361 } ) ;
357362
358- const result = await getGitifySubjectForDiscussion (
363+ const result = await getGitifySubjectDetails (
359364 mockNotification ,
360365 mockAccounts . token ,
361366 ) ;
@@ -370,6 +375,7 @@ describe('utils/state.ts', () => {
370375 subject : {
371376 ...mockedSingleNotification . subject ,
372377 title : 'This is a discussion' ,
378+ type : 'Discussion' as SubjectType ,
373379 } ,
374380 } ;
375381
@@ -402,16 +408,14 @@ describe('utils/state.ts', () => {
402408 } ,
403409 } ) ;
404410
405- const result = await getGitifySubjectForDiscussion (
411+ const result = await getGitifySubjectDetails (
406412 mockNotification ,
407413 mockAccounts . token ,
408414 ) ;
409415
410416 expect ( result . state ) . toBe ( 'OPEN' ) ;
411417 expect ( result . user ) . toBe ( null ) ;
412418 } ) ;
413-
414- it ( 'handles unknown or missing results' , async ( ) => { } ) ;
415419 } ) ;
416420
417421 describe ( 'getGitifySubjectForIssue' , ( ) => {
@@ -424,7 +428,7 @@ describe('utils/state.ts', () => {
424428 . get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
425429 . reply ( 200 , { user : { login : 'some-user' } } ) ;
426430
427- const result = await getGitifySubjectForIssue (
431+ const result = await getGitifySubjectDetails (
428432 mockedSingleNotification ,
429433 mockAccounts . token ,
430434 ) ;
@@ -442,7 +446,7 @@ describe('utils/state.ts', () => {
442446 . get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
443447 . reply ( 200 , { user : { login : 'some-user' } } ) ;
444448
445- const result = await getGitifySubjectForIssue (
449+ const result = await getGitifySubjectDetails (
446450 mockedSingleNotification ,
447451 mockAccounts . token ,
448452 ) ;
@@ -460,7 +464,7 @@ describe('utils/state.ts', () => {
460464 . get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
461465 . reply ( 200 , { user : { login : 'some-user' } } ) ;
462466
463- const result = await getGitifySubjectForIssue (
467+ const result = await getGitifySubjectDetails (
464468 mockedSingleNotification ,
465469 mockAccounts . token ,
466470 ) ;
@@ -478,7 +482,7 @@ describe('utils/state.ts', () => {
478482 . get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
479483 . reply ( 200 , { user : { login : 'some-user' } } ) ;
480484
481- const result = await getGitifySubjectForIssue (
485+ const result = await getGitifySubjectDetails (
482486 mockedSingleNotification ,
483487 mockAccounts . token ,
484488 ) ;
@@ -496,7 +500,7 @@ describe('utils/state.ts', () => {
496500 . get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
497501 . reply ( 200 , { user : { login : 'some-user' } } ) ;
498502
499- const result = await getGitifySubjectForIssue (
503+ const result = await getGitifySubjectDetails (
500504 mockedSingleNotification ,
501505 mockAccounts . token ,
502506 ) ;
@@ -507,6 +511,14 @@ describe('utils/state.ts', () => {
507511 } ) ;
508512
509513 describe ( 'getGitifySubjectForPullRequest' , ( ) => {
514+ const mockNotification = {
515+ ...mockedSingleNotification ,
516+ subject : {
517+ ...mockedSingleNotification . subject ,
518+ type : 'PullRequest' as SubjectType ,
519+ } ,
520+ } ;
521+
510522 it ( 'closed pull request state' , async ( ) => {
511523 nock ( 'https://api.github.com' )
512524 . get ( '/repos/manosim/notifications-test/issues/1' )
@@ -516,8 +528,8 @@ describe('utils/state.ts', () => {
516528 . get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
517529 . reply ( 200 , { user : { login : 'some-user' } } ) ;
518530
519- const result = await getGitifySubjectForPullRequest (
520- mockedSingleNotification ,
531+ const result = await getGitifySubjectDetails (
532+ mockNotification ,
521533 mockAccounts . token ,
522534 ) ;
523535
@@ -534,8 +546,8 @@ describe('utils/state.ts', () => {
534546 . get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
535547 . reply ( 200 , { user : { login : 'some-user' } } ) ;
536548
537- const result = await getGitifySubjectForPullRequest (
538- mockedSingleNotification ,
549+ const result = await getGitifySubjectDetails (
550+ mockNotification ,
539551 mockAccounts . token ,
540552 ) ;
541553
@@ -552,8 +564,8 @@ describe('utils/state.ts', () => {
552564 . get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
553565 . reply ( 200 , { user : { login : 'some-user' } } ) ;
554566
555- const result = await getGitifySubjectForPullRequest (
556- mockedSingleNotification ,
567+ const result = await getGitifySubjectDetails (
568+ mockNotification ,
557569 mockAccounts . token ,
558570 ) ;
559571
@@ -570,8 +582,8 @@ describe('utils/state.ts', () => {
570582 . get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
571583 . reply ( 200 , { user : { login : 'some-user' } } ) ;
572584
573- const result = await getGitifySubjectForPullRequest (
574- mockedSingleNotification ,
585+ const result = await getGitifySubjectDetails (
586+ mockNotification ,
575587 mockAccounts . token ,
576588 ) ;
577589
0 commit comments