@@ -305,6 +305,11 @@ test.after.each(() => {
305305
306306// This test sends a payload that is not an emergency label
307307test ( "recieves pull_request.labeled event, does nothing because not emergency label" , async function ( ) {
308+ // mock the request to check if the user is a member of the emergency team
309+ const mock = nock ( "https://api.github.com" )
310+ . get ( `/orgs/robandpdx/teams/emergency/memberships/robandpdx?org=robandpdx&team_slug=emergency&username=robandpdx` )
311+ . reply ( 200 , payloadMembershipResponse ) ;
312+
308313 await probot . receive ( {
309314 name : "pull_request" ,
310315 id : "1" ,
@@ -321,6 +326,7 @@ test("recieves pull_request.labeled event, does nothing because not emergency la
321326 }
322327 } ,
323328 } ) ;
329+ assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
324330} ) ;
325331
326332// This test will do all 4 things: approve, create issue, merge, and send slack notification
@@ -717,7 +723,7 @@ test("recieves pull_request.labeled event, approve (fails), create issue, merge"
717723 await probot . receive ( payloadPrLabeled ) ;
718724 } catch ( err ) {
719725 assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
720- assert . equal ( err . errors [ 0 ] [ 0 ] . message , "request to https://api.github.com/repos/robandpdx/superbigmono/pulls/1/reviews failed, reason: something awful happened" ) ;
726+ assert . equal ( err . errors [ 0 ] [ 0 ] . message , "something awful happened" ) ;
721727 assert . equal ( err . errors [ 0 ] . length , 1 ) ;
722728 return ;
723729 }
@@ -754,7 +760,7 @@ test("recieves pull_request.labeled event, approve, create issue (fails), merge"
754760 await probot . receive ( payloadPrLabeled ) ;
755761 } catch ( err ) {
756762 assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
757- assert . equal ( err . errors [ 0 ] [ 0 ] . message , "request to https://api.github.com/repos/robandpdx/superbigmono/issues failed, reason: something awful happened" ) ;
763+ assert . equal ( err . errors [ 0 ] [ 0 ] . message , "something awful happened" ) ;
758764 assert . equal ( err . errors [ 0 ] . length , 1 ) ;
759765 return ;
760766 }
@@ -791,7 +797,7 @@ test("recieves pull_request.labeled event, approve, create issue, merge (fails)"
791797 await probot . receive ( payloadPrLabeled ) ;
792798 } catch ( err ) {
793799 assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
794- assert . equal ( err . errors [ 0 ] [ 0 ] . message , "request to https://api.github.com/repos/robandpdx/superbigmono/pulls/1/merge failed, reason: something awful happened" ) ;
800+ assert . equal ( err . errors [ 0 ] [ 0 ] . message , "something awful happened" ) ;
795801 assert . equal ( err . errors [ 0 ] . length , 1 ) ;
796802 return ;
797803 }
@@ -804,7 +810,7 @@ test("recieves pull_request.unlabeled event, reapply emergency label", async fun
804810 const mock = nock ( "https://api.github.com" )
805811 . post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
806812 ( requestBody ) => {
807- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
813+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
808814 return true ;
809815 }
810816 )
@@ -828,7 +834,7 @@ test("recieves pull_request.unlabeled event, fail to reapply emergency label", a
828834 const mock = nock ( "https://api.github.com" )
829835 . post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
830836 ( requestBody ) => {
831- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
837+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
832838 return true ;
833839 }
834840 )
@@ -838,7 +844,7 @@ test("recieves pull_request.unlabeled event, fail to reapply emergency label", a
838844 await probot . receive ( payloadUnlabeled ) ;
839845 } catch ( err ) {
840846 assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
841- assert . equal ( err . errors [ 0 ] [ 0 ] . message , "request to https://api.github.com/repos/robandpdx/superbigmono/issues/1/labels failed, reason: something awful happened" ) ;
847+ assert . equal ( err . errors [ 0 ] [ 0 ] . message , "something awful happened" ) ;
842848 assert . equal ( err . errors [ 0 ] . length , 1 ) ;
843849 return ;
844850 }
@@ -859,7 +865,7 @@ test("recieves issue.unlabeled event, reapply emergency label", async function (
859865 const mock = nock ( "https://api.github.com" )
860866 . post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
861867 ( requestBody ) => {
862- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
868+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
863869 return true ;
864870 }
865871 )
@@ -883,7 +889,7 @@ test("recieves issue.unlabeled event, fail to reapply emergency label", async fu
883889 const mock = nock ( "https://api.github.com" )
884890 . post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
885891 ( requestBody ) => {
886- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
892+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
887893 return true ;
888894 }
889895 )
@@ -893,7 +899,7 @@ test("recieves issue.unlabeled event, fail to reapply emergency label", async fu
893899 await probot . receive ( payloadIssueUnlabeled ) ;
894900 } catch ( err ) {
895901 assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
896- assert . equal ( err . errors [ 0 ] [ 0 ] . message , "request to https://api.github.com/repos/robandpdx/superbigmono/issues/1/labels failed, reason: something awful happened" ) ;
902+ assert . equal ( err . errors [ 0 ] [ 0 ] . message , "something awful happened" ) ;
897903 assert . equal ( err . errors [ 0 ] . length , 1 ) ;
898904 return ;
899905 }
@@ -913,7 +919,7 @@ test("recieves pull_request.opened event, applies emergency label", async functi
913919 const mock = nock ( "https://api.github.com" )
914920 . post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
915921 ( requestBody ) => {
916- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
922+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
917923 return true ;
918924 }
919925 )
@@ -931,7 +937,7 @@ test("recieves pull_request.opened event, applies emergency label checking team
931937 const mock = nock ( "https://api.github.com" )
932938 . post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
933939 ( requestBody ) => {
934- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
940+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
935941 return true ;
936942 }
937943 )
@@ -972,7 +978,7 @@ test("recieves pull_request.opened event, fails to apply emergency label", async
972978 const mock = nock ( "https://api.github.com" )
973979 . post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
974980 ( requestBody ) => {
975- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
981+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
976982 return true ;
977983 }
978984 )
@@ -982,7 +988,7 @@ test("recieves pull_request.opened event, fails to apply emergency label", async
982988 await probot . receive ( payloadPrOpened ) ;
983989 } catch ( err ) {
984990 assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
985- assert . equal ( err . errors [ 0 ] [ 0 ] . message , "request to https://api.github.com/repos/robandpdx/superbigmono/issues/1/labels failed, reason: something awful happened" ) ;
991+ assert . equal ( err . errors [ 0 ] [ 0 ] . message , "something awful happened" ) ;
986992 assert . equal ( err . errors [ 0 ] . length , 1 ) ;
987993 return ;
988994 }
@@ -1000,7 +1006,7 @@ test("recieves issue_comment.created event, applies emergency label", async func
10001006 const mock = nock ( "https://api.github.com" )
10011007 . post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
10021008 ( requestBody ) => {
1003- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
1009+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
10041010 return true ;
10051011 }
10061012 )
@@ -1018,7 +1024,7 @@ test("recieves issue_comment.created event, applies emergency label", async func
10181024 const mock = nock ( "https://api.github.com" )
10191025 . post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
10201026 ( requestBody ) => {
1021- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
1027+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
10221028 return true ;
10231029 }
10241030 )
@@ -1102,7 +1108,7 @@ test("recieves issue_comment.created event, failes to apply emergency label", as
11021108 const mock = nock ( "https://api.github.com" )
11031109 . post ( "/repos/robandpdx/superbigmono/issues/1/labels" ,
11041110 ( requestBody ) => {
1105- assert . equal ( requestBody [ 0 ] , "emergency" ) ;
1111+ assert . equal ( requestBody . labels [ 0 ] , "emergency" ) ;
11061112 return true ;
11071113 }
11081114 )
@@ -1112,7 +1118,7 @@ test("recieves issue_comment.created event, failes to apply emergency label", as
11121118 await probot . receive ( payloadPrComment ) ;
11131119 } catch ( err ) {
11141120 assert . equal ( mock . pendingMocks ( ) , [ ] ) ;
1115- assert . equal ( err . errors [ 0 ] [ 0 ] . message , "request to https://api.github.com/repos/robandpdx/superbigmono/issues/1/labels failed, reason: something awful happened" ) ;
1121+ assert . equal ( err . errors [ 0 ] [ 0 ] . message , "something awful happened" ) ;
11161122 assert . equal ( err . errors [ 0 ] . length , 1 ) ;
11171123 return ;
11181124 }
0 commit comments