@@ -565,30 +565,63 @@ describe('utils/subject.ts', () => {
565
565
} ) ;
566
566
} ) ;
567
567
568
- it ( 'issue with labels' , async ( ) => {
569
- nock ( 'https://api.github.com' )
570
- . get ( '/repos/gitify-app/notifications-test/issues/1' )
571
- . reply ( 200 , {
568
+ describe ( 'Issue With Labels' , ( ) => {
569
+ it ( 'with labels' , async ( ) => {
570
+ nock ( 'https://api.github.com' )
571
+ . get ( '/repos/gitify-app/notifications-test/issues/1' )
572
+ . reply ( 200 , {
573
+ state : 'open' ,
574
+ user : mockAuthor ,
575
+ labels : [ { name : 'enhancement' } ] ,
576
+ } ) ;
577
+
578
+ nock ( 'https://api.github.com' )
579
+ . get (
580
+ '/repos/gitify-app/notifications-test/issues/comments/302888448' ,
581
+ )
582
+ . reply ( 200 , { user : mockCommenter } ) ;
583
+
584
+ const result = await getGitifySubjectDetails ( mockNotification ) ;
585
+
586
+ expect ( result ) . toEqual ( {
572
587
state : 'open' ,
573
- user : mockAuthor ,
574
- labels : [ { name : 'enhancement' } ] ,
588
+ user : {
589
+ login : mockCommenter . login ,
590
+ html_url : mockCommenter . html_url ,
591
+ avatar_url : mockCommenter . avatar_url ,
592
+ type : mockCommenter . type ,
593
+ } ,
594
+ labels : [ 'enhancement' ] ,
575
595
} ) ;
596
+ } ) ;
576
597
577
- nock ( 'https://api.github.com' )
578
- . get ( '/repos/gitify-app/notifications-test/issues/comments/302888448' )
579
- . reply ( 200 , { user : mockCommenter } ) ;
598
+ it ( 'handle null labels' , async ( ) => {
599
+ nock ( 'https://api.github.com' )
600
+ . get ( '/repos/gitify-app/notifications-test/issues/1' )
601
+ . reply ( 200 , {
602
+ state : 'open' ,
603
+ user : mockAuthor ,
604
+ labels : null ,
605
+ } ) ;
580
606
581
- const result = await getGitifySubjectDetails ( mockNotification ) ;
607
+ nock ( 'https://api.github.com' )
608
+ . get (
609
+ '/repos/gitify-app/notifications-test/issues/comments/302888448' ,
610
+ )
611
+ . reply ( 200 , { user : mockCommenter } ) ;
582
612
583
- expect ( result ) . toEqual ( {
584
- state : 'open' ,
585
- user : {
586
- login : mockCommenter . login ,
587
- html_url : mockCommenter . html_url ,
588
- avatar_url : mockCommenter . avatar_url ,
589
- type : mockCommenter . type ,
590
- } ,
591
- labels : [ 'enhancement' ] ,
613
+ const result = await getGitifySubjectDetails ( mockNotification ) ;
614
+
615
+ expect ( result ) . toEqual ( {
616
+ state : 'open' ,
617
+ user : {
618
+ login : mockCommenter . login ,
619
+ html_url : mockCommenter . html_url ,
620
+ avatar_url : mockCommenter . avatar_url ,
621
+ type : mockCommenter . type ,
622
+ } ,
623
+ labels : [ ] ,
624
+ } ) ;
592
625
} ) ;
593
626
} ) ;
594
627
} ) ;
@@ -871,38 +904,79 @@ describe('utils/subject.ts', () => {
871
904
} ) ;
872
905
} ) ;
873
906
874
- it ( 'Pull Requests With labels' , async ( ) => {
875
- nock ( 'https://api.github.com' )
876
- . get ( '/repos/gitify-app/notifications-test/pulls/1' )
877
- . reply ( 200 , {
907
+ describe ( 'Pull Requests With Labels' , ( ) => {
908
+ it ( 'with labels' , async ( ) => {
909
+ nock ( 'https://api.github.com' )
910
+ . get ( '/repos/gitify-app/notifications-test/pulls/1' )
911
+ . reply ( 200 , {
912
+ state : 'open' ,
913
+ draft : false ,
914
+ merged : false ,
915
+ user : mockAuthor ,
916
+ labels : [ { name : 'enhancement' } ] ,
917
+ } ) ;
918
+
919
+ nock ( 'https://api.github.com' )
920
+ . get (
921
+ '/repos/gitify-app/notifications-test/issues/comments/302888448' ,
922
+ )
923
+ . reply ( 200 , { user : mockCommenter } ) ;
924
+
925
+ nock ( 'https://api.github.com' )
926
+ . get ( '/repos/gitify-app/notifications-test/pulls/1/reviews' )
927
+ . reply ( 200 , [ ] ) ;
928
+
929
+ const result = await getGitifySubjectDetails ( mockNotification ) ;
930
+
931
+ expect ( result ) . toEqual ( {
878
932
state : 'open' ,
879
- draft : false ,
880
- merged : false ,
881
- user : mockAuthor ,
882
- labels : [ { name : 'enhancement' } ] ,
933
+ user : {
934
+ login : mockCommenter . login ,
935
+ html_url : mockCommenter . html_url ,
936
+ avatar_url : mockCommenter . avatar_url ,
937
+ type : mockCommenter . type ,
938
+ } ,
939
+ reviews : null ,
940
+ labels : [ 'enhancement' ] ,
941
+ linkedIssues : [ ] ,
883
942
} ) ;
943
+ } ) ;
884
944
885
- nock ( 'https://api.github.com' )
886
- . get ( '/repos/gitify-app/notifications-test/issues/comments/302888448' )
887
- . reply ( 200 , { user : mockCommenter } ) ;
945
+ it ( 'handle null labels' , async ( ) => {
946
+ nock ( 'https://api.github.com' )
947
+ . get ( '/repos/gitify-app/notifications-test/pulls/1' )
948
+ . reply ( 200 , {
949
+ state : 'open' ,
950
+ draft : false ,
951
+ merged : false ,
952
+ user : mockAuthor ,
953
+ labels : null ,
954
+ } ) ;
888
955
889
- nock ( 'https://api.github.com' )
890
- . get ( '/repos/gitify-app/notifications-test/pulls/1/reviews' )
891
- . reply ( 200 , [ ] ) ;
956
+ nock ( 'https://api.github.com' )
957
+ . get (
958
+ '/repos/gitify-app/notifications-test/issues/comments/302888448' ,
959
+ )
960
+ . reply ( 200 , { user : mockCommenter } ) ;
892
961
893
- const result = await getGitifySubjectDetails ( mockNotification ) ;
962
+ nock ( 'https://api.github.com' )
963
+ . get ( '/repos/gitify-app/notifications-test/pulls/1/reviews' )
964
+ . reply ( 200 , [ ] ) ;
894
965
895
- expect ( result ) . toEqual ( {
896
- state : 'open' ,
897
- user : {
898
- login : mockCommenter . login ,
899
- html_url : mockCommenter . html_url ,
900
- avatar_url : mockCommenter . avatar_url ,
901
- type : mockCommenter . type ,
902
- } ,
903
- reviews : null ,
904
- labels : [ 'enhancement' ] ,
905
- linkedIssues : [ ] ,
966
+ const result = await getGitifySubjectDetails ( mockNotification ) ;
967
+
968
+ expect ( result ) . toEqual ( {
969
+ state : 'open' ,
970
+ user : {
971
+ login : mockCommenter . login ,
972
+ html_url : mockCommenter . html_url ,
973
+ avatar_url : mockCommenter . avatar_url ,
974
+ type : mockCommenter . type ,
975
+ } ,
976
+ reviews : null ,
977
+ labels : [ ] ,
978
+ linkedIssues : [ ] ,
979
+ } ) ;
906
980
} ) ;
907
981
} ) ;
908
982
0 commit comments