@@ -118,66 +118,6 @@ describe('GitHub', function () {
118
118
} ) ;
119
119
} ) ;
120
120
121
- describe ( '#setIssueLabels' , ( ) => {
122
- let scope ;
123
- const ISSUE_NUMBER = 123 ;
124
- const LABELS = [ 'bug' , 'enhancement' ] ;
125
-
126
- before ( async ( ) => {
127
- scope = nock ( 'https://api.github.com' )
128
- . put ( `/repos/owner/repo/issues/${ ISSUE_NUMBER } /labels` , { labels : LABELS } )
129
- . reply ( 200 ) ;
130
-
131
- await github . setIssueLabels ( { issue : { number : ISSUE_NUMBER } , labels : LABELS } ) ;
132
- } ) ;
133
-
134
- after ( nock . cleanAll ) ;
135
-
136
- it ( 'sets labels on the issue' , ( ) => {
137
- expect ( scope . isDone ( ) ) . to . be . true ;
138
- } ) ;
139
- } ) ;
140
-
141
- describe ( '#openIssue' , ( ) => {
142
- let scope ;
143
- const ISSUE = { number : 123 } ;
144
- const EXPECTED_REQUEST_BODY = { state : 'open' } ;
145
-
146
- before ( async ( ) => {
147
- scope = nock ( 'https://api.github.com' )
148
- . patch ( `/repos/owner/repo/issues/${ ISSUE . number } ` , EXPECTED_REQUEST_BODY )
149
- . reply ( 200 ) ;
150
-
151
- await github . openIssue ( ISSUE ) ;
152
- } ) ;
153
-
154
- after ( nock . cleanAll ) ;
155
-
156
- it ( 'opens the issue' , ( ) => {
157
- expect ( scope . isDone ( ) ) . to . be . true ;
158
- } ) ;
159
- } ) ;
160
-
161
- describe ( '#closeIssue' , ( ) => {
162
- let scope ;
163
- const ISSUE = { number : 123 } ;
164
- const EXPECTED_REQUEST_BODY = { state : 'closed' } ;
165
-
166
- before ( async ( ) => {
167
- scope = nock ( 'https://api.github.com' )
168
- . patch ( `/repos/owner/repo/issues/${ ISSUE . number } ` , EXPECTED_REQUEST_BODY )
169
- . reply ( 200 ) ;
170
-
171
- await github . closeIssue ( ISSUE ) ;
172
- } ) ;
173
-
174
- after ( nock . cleanAll ) ;
175
-
176
- it ( 'closes the issue' , ( ) => {
177
- expect ( scope . isDone ( ) ) . to . be . true ;
178
- } ) ;
179
- } ) ;
180
-
181
121
describe ( '#getIssue' , ( ) => {
182
122
let scope ;
183
123
let result ;
@@ -376,9 +316,8 @@ describe('GitHub', function () {
376
316
} ;
377
317
378
318
context ( 'when issue is closed' , ( ) => {
379
- let setIssueLabelsScope ;
319
+ let updateIssueScope ;
380
320
let addCommentScope ;
381
- let openIssueScope ;
382
321
383
322
const GITHUB_RESPONSE_FOR_EXISTING_ISSUE = {
384
323
number : 123 ,
@@ -394,12 +333,8 @@ describe('GitHub', function () {
394
333
. query ( true )
395
334
. reply ( 200 , [ GITHUB_RESPONSE_FOR_EXISTING_ISSUE ] ) ;
396
335
397
- openIssueScope = nock ( 'https://api.github.com' )
398
- . patch ( `/repos/owner/repo/issues/${ GITHUB_RESPONSE_FOR_EXISTING_ISSUE . number } ` , { state : GitHub . ISSUE_STATE_OPEN } )
399
- . reply ( 200 ) ;
400
-
401
- setIssueLabelsScope = nock ( 'https://api.github.com' )
402
- . put ( `/repos/owner/repo/issues/${ GITHUB_RESPONSE_FOR_EXISTING_ISSUE . number } /labels` , { labels : [ 'location' ] } )
336
+ updateIssueScope = nock ( 'https://api.github.com' )
337
+ . patch ( `/repos/owner/repo/issues/${ GITHUB_RESPONSE_FOR_EXISTING_ISSUE . number } ` , { state : GitHub . ISSUE_STATE_OPEN , labels : [ 'location' ] } )
403
338
. reply ( 200 ) ;
404
339
405
340
addCommentScope = nock ( 'https://api.github.com' )
@@ -409,12 +344,8 @@ describe('GitHub', function () {
409
344
await github . createOrUpdateIssue ( ISSUE ) ;
410
345
} ) ;
411
346
412
- it ( 'reopens the issue' , ( ) => {
413
- expect ( openIssueScope . isDone ( ) ) . to . be . true ;
414
- } ) ;
415
-
416
- it ( "updates the issue's label" , ( ) => {
417
- expect ( setIssueLabelsScope . isDone ( ) ) . to . be . true ;
347
+ it ( 'reopens the issue and its labels' , ( ) => {
348
+ expect ( updateIssueScope . isDone ( ) ) . to . be . true ;
418
349
} ) ;
419
350
420
351
it ( 'adds comment to the issue' , ( ) => {
@@ -423,9 +354,8 @@ describe('GitHub', function () {
423
354
} ) ;
424
355
425
356
context ( 'when issue is already opened' , ( ) => {
426
- let setIssueLabelsScope ;
427
357
let addCommentScope ;
428
- let openIssueScope ;
358
+ let updateIssueScope ;
429
359
430
360
const GITHUB_RESPONSE_FOR_EXISTING_ISSUE = {
431
361
number : 123 ,
@@ -441,12 +371,8 @@ describe('GitHub', function () {
441
371
. query ( true )
442
372
. reply ( 200 , [ GITHUB_RESPONSE_FOR_EXISTING_ISSUE ] ) ;
443
373
444
- openIssueScope = nock ( 'https://api.github.com' )
445
- . patch ( `/repos/owner/repo/issues/${ GITHUB_RESPONSE_FOR_EXISTING_ISSUE . number } ` , { state : GitHub . ISSUE_STATE_OPEN } )
446
- . reply ( 200 ) ;
447
-
448
- setIssueLabelsScope = nock ( 'https://api.github.com' )
449
- . put ( `/repos/owner/repo/issues/${ GITHUB_RESPONSE_FOR_EXISTING_ISSUE . number } /labels` , { labels : [ 'location' ] } )
374
+ updateIssueScope = nock ( 'https://api.github.com' )
375
+ . patch ( `/repos/owner/repo/issues/${ GITHUB_RESPONSE_FOR_EXISTING_ISSUE . number } ` , { state : GitHub . ISSUE_STATE_OPEN , labels : [ 'location' ] } )
450
376
. reply ( 200 ) ;
451
377
452
378
addCommentScope = nock ( 'https://api.github.com' )
@@ -456,12 +382,8 @@ describe('GitHub', function () {
456
382
await github . createOrUpdateIssue ( ISSUE ) ;
457
383
} ) ;
458
384
459
- it ( 'does not change the issue state' , ( ) => {
460
- expect ( openIssueScope . isDone ( ) ) . to . be . false ;
461
- } ) ;
462
-
463
- it ( "updates the issue's label" , ( ) => {
464
- expect ( setIssueLabelsScope . isDone ( ) ) . to . be . true ;
385
+ it ( "updates the issue's labels" , ( ) => {
386
+ expect ( updateIssueScope . isDone ( ) ) . to . be . true ;
465
387
} ) ;
466
388
467
389
it ( 'adds comment to the issue' , ( ) => {
0 commit comments