@@ -121,6 +121,23 @@ describe('Github API best practices', function () {
121
121
expect ( octokit . __requestTimings [ 5 ] - octokit . __requestTimings [ 0 ] ) . to . be . closeTo ( 100 , 20 )
122
122
} )
123
123
124
+ it ( 'Should match custom routes when checking notification triggers' , function ( ) {
125
+ const plugin = require ( '../lib' )
126
+
127
+ expect ( plugin . triggersNotification ( '/abc/def' ) ) . to . equal ( false )
128
+ expect ( plugin . triggersNotification ( '/orgs/abc/invitation' ) ) . to . equal ( false )
129
+ expect ( plugin . triggersNotification ( '/repos/abc/releases' ) ) . to . equal ( false )
130
+ expect ( plugin . triggersNotification ( '/repos/abc/def/pulls/5' ) ) . to . equal ( false )
131
+
132
+ expect ( plugin . triggersNotification ( '/repos/abc/def/pulls' ) ) . to . equal ( true )
133
+ expect ( plugin . triggersNotification ( '/repos/abc/def/pulls/5/comments' ) ) . to . equal ( true )
134
+ expect ( plugin . triggersNotification ( '/repos/foo/bar/issues' ) ) . to . equal ( true )
135
+
136
+ expect ( plugin . triggersNotification ( '/repos/:owner/:repo/pulls' ) ) . to . equal ( true )
137
+ expect ( plugin . triggersNotification ( '/repos/:owner/:repo/pulls/5/comments' ) ) . to . equal ( true )
138
+ expect ( plugin . triggersNotification ( '/repos/:foo/:bar/issues' ) ) . to . equal ( true )
139
+ } )
140
+
124
141
it ( 'Should optimize throughput rather than maintain ordering' , async function ( ) {
125
142
const octokit = new Octokit ( {
126
143
throttle : {
@@ -131,7 +148,7 @@ describe('Github API best practices', function () {
131
148
}
132
149
} )
133
150
134
- const req1 = octokit . request ( 'POST /orgs/:org /invitations' , {
151
+ const req1 = octokit . request ( 'POST /orgs/abc /invitations' , {
135
152
request : {
136
153
responses : [ { status : 200 , headers : { } , data : { } } ]
137
154
}
@@ -151,12 +168,12 @@ describe('Github API best practices', function () {
151
168
responses : [ { status : 200 , headers : { } , data : { } } ]
152
169
}
153
170
} )
154
- const req5 = octokit . request ( 'POST /repos/:owner/:repo /commits/:sha /comments' , {
171
+ const req5 = octokit . request ( 'POST /repos/abc/def /commits/12345 /comments' , {
155
172
request : {
156
173
responses : [ { status : 200 , headers : { } , data : { } } ]
157
174
}
158
175
} )
159
- const req6 = octokit . request ( 'PATCH /orgs/:org /invitations' , {
176
+ const req6 = octokit . request ( 'PATCH /orgs/abc /invitations' , {
160
177
request : {
161
178
responses : [ { status : 200 , headers : { } , data : { } } ]
162
179
}
@@ -173,14 +190,14 @@ describe('Github API best practices', function () {
173
190
'END GET /route2' ,
174
191
'START GET /route4' ,
175
192
'END GET /route4' ,
176
- 'START POST /orgs/:org /invitations' ,
177
- 'END POST /orgs/:org /invitations' ,
193
+ 'START POST /orgs/abc /invitations' ,
194
+ 'END POST /orgs/abc /invitations' ,
178
195
'START POST /route3' ,
179
196
'END POST /route3' ,
180
- 'START POST /repos/:owner/:repo /commits/:sha /comments' ,
181
- 'END POST /repos/:owner/:repo /commits/:sha /comments' ,
182
- 'START PATCH /orgs/:org /invitations' ,
183
- 'END PATCH /orgs/:org /invitations' ,
197
+ 'START POST /repos/abc/def /commits/12345 /comments' ,
198
+ 'END POST /repos/abc/def /commits/12345 /comments' ,
199
+ 'START PATCH /orgs/abc /invitations' ,
200
+ 'END PATCH /orgs/abc /invitations' ,
184
201
'START GET /route6' ,
185
202
'END GET /route6'
186
203
] )
0 commit comments