@@ -5,11 +5,10 @@ import { mockAccounts } from '../__mocks__/mock-state';
5
5
import { mockedSingleNotification } from '../__mocks__/mockedData' ;
6
6
import {
7
7
getCheckSuiteAttributes ,
8
- getGitifySubjectForDiscussion ,
9
- getGitifySubjectForIssue ,
10
- getGitifySubjectForPullRequest ,
8
+ getGitifySubjectDetails ,
11
9
getWorkflowRunAttributes ,
12
10
} from './subject' ;
11
+ import { SubjectType } from '../typesGithub' ;
13
12
describe ( 'utils/state.ts' , ( ) => {
14
13
beforeEach ( ( ) => {
15
14
// axios will default to using the XHR adapter which can't be intercepted
@@ -142,6 +141,7 @@ describe('utils/state.ts', () => {
142
141
subject : {
143
142
...mockedSingleNotification . subject ,
144
143
title : 'This is an answered discussion' ,
144
+ type : 'Discussion' as SubjectType ,
145
145
} ,
146
146
} ;
147
147
@@ -165,7 +165,7 @@ describe('utils/state.ts', () => {
165
165
} ,
166
166
} ) ;
167
167
168
- const result = await getGitifySubjectForDiscussion (
168
+ const result = await getGitifySubjectDetails (
169
169
mockNotification ,
170
170
mockAccounts . token ,
171
171
) ;
@@ -180,6 +180,7 @@ describe('utils/state.ts', () => {
180
180
subject : {
181
181
...mockedSingleNotification . subject ,
182
182
title : 'This is a duplicate discussion' ,
183
+ type : 'Discussion' as SubjectType ,
183
184
} ,
184
185
} ;
185
186
@@ -203,7 +204,7 @@ describe('utils/state.ts', () => {
203
204
} ,
204
205
} ) ;
205
206
206
- const result = await getGitifySubjectForDiscussion (
207
+ const result = await getGitifySubjectDetails (
207
208
mockNotification ,
208
209
mockAccounts . token ,
209
210
) ;
@@ -218,6 +219,7 @@ describe('utils/state.ts', () => {
218
219
subject : {
219
220
...mockedSingleNotification . subject ,
220
221
title : 'This is an open discussion' ,
222
+ type : 'Discussion' as SubjectType ,
221
223
} ,
222
224
} ;
223
225
@@ -241,7 +243,7 @@ describe('utils/state.ts', () => {
241
243
} ,
242
244
} ) ;
243
245
244
- const result = await getGitifySubjectForDiscussion (
246
+ const result = await getGitifySubjectDetails (
245
247
mockNotification ,
246
248
mockAccounts . token ,
247
249
) ;
@@ -256,6 +258,7 @@ describe('utils/state.ts', () => {
256
258
subject : {
257
259
...mockedSingleNotification . subject ,
258
260
title : 'This is an outdated discussion' ,
261
+ type : 'Discussion' as SubjectType ,
259
262
} ,
260
263
} ;
261
264
@@ -279,7 +282,7 @@ describe('utils/state.ts', () => {
279
282
} ,
280
283
} ) ;
281
284
282
- const result = await getGitifySubjectForDiscussion (
285
+ const result = await getGitifySubjectDetails (
283
286
mockNotification ,
284
287
mockAccounts . token ,
285
288
) ;
@@ -294,6 +297,7 @@ describe('utils/state.ts', () => {
294
297
subject : {
295
298
...mockedSingleNotification . subject ,
296
299
title : 'This is a reopened discussion' ,
300
+ type : 'Discussion' as SubjectType ,
297
301
} ,
298
302
} ;
299
303
@@ -317,7 +321,7 @@ describe('utils/state.ts', () => {
317
321
} ,
318
322
} ) ;
319
323
320
- const result = await getGitifySubjectForDiscussion (
324
+ const result = await getGitifySubjectDetails (
321
325
mockNotification ,
322
326
mockAccounts . token ,
323
327
) ;
@@ -332,6 +336,7 @@ describe('utils/state.ts', () => {
332
336
subject : {
333
337
...mockedSingleNotification . subject ,
334
338
title : 'This is a resolved discussion' ,
339
+ type : 'Discussion' as SubjectType ,
335
340
} ,
336
341
} ;
337
342
@@ -355,7 +360,7 @@ describe('utils/state.ts', () => {
355
360
} ,
356
361
} ) ;
357
362
358
- const result = await getGitifySubjectForDiscussion (
363
+ const result = await getGitifySubjectDetails (
359
364
mockNotification ,
360
365
mockAccounts . token ,
361
366
) ;
@@ -370,6 +375,7 @@ describe('utils/state.ts', () => {
370
375
subject : {
371
376
...mockedSingleNotification . subject ,
372
377
title : 'This is a discussion' ,
378
+ type : 'Discussion' as SubjectType ,
373
379
} ,
374
380
} ;
375
381
@@ -402,16 +408,14 @@ describe('utils/state.ts', () => {
402
408
} ,
403
409
} ) ;
404
410
405
- const result = await getGitifySubjectForDiscussion (
411
+ const result = await getGitifySubjectDetails (
406
412
mockNotification ,
407
413
mockAccounts . token ,
408
414
) ;
409
415
410
416
expect ( result . state ) . toBe ( 'OPEN' ) ;
411
417
expect ( result . user ) . toBe ( null ) ;
412
418
} ) ;
413
-
414
- it ( 'handles unknown or missing results' , async ( ) => { } ) ;
415
419
} ) ;
416
420
417
421
describe ( 'getGitifySubjectForIssue' , ( ) => {
@@ -424,7 +428,7 @@ describe('utils/state.ts', () => {
424
428
. get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
425
429
. reply ( 200 , { user : { login : 'some-user' } } ) ;
426
430
427
- const result = await getGitifySubjectForIssue (
431
+ const result = await getGitifySubjectDetails (
428
432
mockedSingleNotification ,
429
433
mockAccounts . token ,
430
434
) ;
@@ -442,7 +446,7 @@ describe('utils/state.ts', () => {
442
446
. get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
443
447
. reply ( 200 , { user : { login : 'some-user' } } ) ;
444
448
445
- const result = await getGitifySubjectForIssue (
449
+ const result = await getGitifySubjectDetails (
446
450
mockedSingleNotification ,
447
451
mockAccounts . token ,
448
452
) ;
@@ -460,7 +464,7 @@ describe('utils/state.ts', () => {
460
464
. get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
461
465
. reply ( 200 , { user : { login : 'some-user' } } ) ;
462
466
463
- const result = await getGitifySubjectForIssue (
467
+ const result = await getGitifySubjectDetails (
464
468
mockedSingleNotification ,
465
469
mockAccounts . token ,
466
470
) ;
@@ -478,7 +482,7 @@ describe('utils/state.ts', () => {
478
482
. get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
479
483
. reply ( 200 , { user : { login : 'some-user' } } ) ;
480
484
481
- const result = await getGitifySubjectForIssue (
485
+ const result = await getGitifySubjectDetails (
482
486
mockedSingleNotification ,
483
487
mockAccounts . token ,
484
488
) ;
@@ -496,7 +500,7 @@ describe('utils/state.ts', () => {
496
500
. get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
497
501
. reply ( 200 , { user : { login : 'some-user' } } ) ;
498
502
499
- const result = await getGitifySubjectForIssue (
503
+ const result = await getGitifySubjectDetails (
500
504
mockedSingleNotification ,
501
505
mockAccounts . token ,
502
506
) ;
@@ -507,6 +511,14 @@ describe('utils/state.ts', () => {
507
511
} ) ;
508
512
509
513
describe ( 'getGitifySubjectForPullRequest' , ( ) => {
514
+ const mockNotification = {
515
+ ...mockedSingleNotification ,
516
+ subject : {
517
+ ...mockedSingleNotification . subject ,
518
+ type : 'PullRequest' as SubjectType ,
519
+ } ,
520
+ } ;
521
+
510
522
it ( 'closed pull request state' , async ( ) => {
511
523
nock ( 'https://api.github.com' )
512
524
. get ( '/repos/manosim/notifications-test/issues/1' )
@@ -516,8 +528,8 @@ describe('utils/state.ts', () => {
516
528
. get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
517
529
. reply ( 200 , { user : { login : 'some-user' } } ) ;
518
530
519
- const result = await getGitifySubjectForPullRequest (
520
- mockedSingleNotification ,
531
+ const result = await getGitifySubjectDetails (
532
+ mockNotification ,
521
533
mockAccounts . token ,
522
534
) ;
523
535
@@ -534,8 +546,8 @@ describe('utils/state.ts', () => {
534
546
. get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
535
547
. reply ( 200 , { user : { login : 'some-user' } } ) ;
536
548
537
- const result = await getGitifySubjectForPullRequest (
538
- mockedSingleNotification ,
549
+ const result = await getGitifySubjectDetails (
550
+ mockNotification ,
539
551
mockAccounts . token ,
540
552
) ;
541
553
@@ -552,8 +564,8 @@ describe('utils/state.ts', () => {
552
564
. get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
553
565
. reply ( 200 , { user : { login : 'some-user' } } ) ;
554
566
555
- const result = await getGitifySubjectForPullRequest (
556
- mockedSingleNotification ,
567
+ const result = await getGitifySubjectDetails (
568
+ mockNotification ,
557
569
mockAccounts . token ,
558
570
) ;
559
571
@@ -570,8 +582,8 @@ describe('utils/state.ts', () => {
570
582
. get ( '/repos/manosim/notifications-test/issues/comments/302888448' )
571
583
. reply ( 200 , { user : { login : 'some-user' } } ) ;
572
584
573
- const result = await getGitifySubjectForPullRequest (
574
- mockedSingleNotification ,
585
+ const result = await getGitifySubjectDetails (
586
+ mockNotification ,
575
587
mockAccounts . token ,
576
588
) ;
577
589
0 commit comments