volunteer-contributions-fetch 2.3.2 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ const config = {
11
11
  stopDate: new Date('2022-01-01'),
12
12
  filter: '',
13
13
  delayMsPerRequest: 0,
14
- }
14
+ },
15
15
  };
16
16
 
17
17
  test.beforeEach((t) => {
@@ -83,35 +83,49 @@ test.serial('should not fetch if disabled - by enable property', async (t) => {
83
83
  t.is(contributions.length, 0);
84
84
  });
85
85
 
86
- test.serial('should not fetch if disabled - by leaving off config value', async (t) => {
87
- const contributions = await github.gather({});
88
-
89
- t.is(contributions.length, 0);
90
- });
86
+ test.serial(
87
+ 'should not fetch if disabled - by leaving off config value',
88
+ async (t) => {
89
+ const contributions = await github.gather({});
91
90
 
92
- test.serial('should throw if private repo scope token is used and config does not allow private repo access', async (t) => {
93
- fetcher.throwIfTokenHasPrivateRepoScope.rejects(new Error('PRIVATE_SCOPE'));
91
+ t.is(contributions.length, 0);
92
+ }
93
+ );
94
94
 
95
- await t.throwsAsync(() => github.gather(config));
96
- });
95
+ test.serial(
96
+ 'should throw if private repo scope token is used and config does not allow private repo access',
97
+ async (t) => {
98
+ fetcher.throwIfTokenHasPrivateRepoScope.rejects(new Error('PRIVATE_SCOPE'));
97
99
 
98
- test.serial('should not throw if private repo scope token is used but config does allow private repo access', async (t) => {
99
- fetcher.throwIfTokenHasPrivateRepoScope.rejects(new Error('PRIVATE_SCOPE'));
100
- const allowedPrivateConfig = {
101
- github: {
102
- ...config.github,
103
- allowPrivate: true,
104
- },
105
- };
100
+ await t.throwsAsync(() => github.gather(config));
101
+ }
102
+ );
103
+
104
+ test.serial(
105
+ 'should not throw if private repo scope token is used but config does allow private repo access',
106
+ async (t) => {
107
+ fetcher.throwIfTokenHasPrivateRepoScope.rejects(new Error('PRIVATE_SCOPE'));
108
+ const allowedPrivateConfig = {
109
+ github: {
110
+ ...config.github,
111
+ allowPrivate: true,
112
+ },
113
+ };
106
114
 
107
- t.notThrows(() => github.gather(allowedPrivateConfig));
108
- });
115
+ t.notThrows(() => github.gather(allowedPrivateConfig));
116
+ }
117
+ );
109
118
 
110
- test.serial('should throw if error is not specifically private scope error', async (t) => {
111
- fetcher.throwIfTokenHasPrivateRepoScope.rejects(new Error('SOMETHING_ELSE'));
119
+ test.serial(
120
+ 'should throw if error is not specifically private scope error',
121
+ async (t) => {
122
+ fetcher.throwIfTokenHasPrivateRepoScope.rejects(
123
+ new Error('SOMETHING_ELSE')
124
+ );
112
125
 
113
- await t.throwsAsync(() => github.gather(config));
114
- });
126
+ await t.throwsAsync(() => github.gather(config));
127
+ }
128
+ );
115
129
 
116
130
  test.serial('should fetch commits until stop date', async (t) => {
117
131
  const commitConfig = {
@@ -125,9 +139,21 @@ test.serial('should fetch commits until stop date', async (t) => {
125
139
  // We want to fetch 2 pages for the first period, and one page for the subsequent periods.
126
140
  // We expect 3 periods to be queried based on the passed stopDate and the faked clock.
127
141
  fetcher.searchCommits.resolves([]);
128
- fetcher.searchCommits.onCall(0).resolves(new Array(100).fill(0).map(() => ({ createdAt: new Date('2022-03-01') })));
129
- fetcher.searchCommits.onCall(1).resolves(new Array(5).fill(0).map(() => ({ createdAt: new Date('2022-02-01') })));
130
- fetcher.searchCommits.onCall(2).resolves(new Array(5).fill(0).map(() => ({ createdAt: new Date('2022-01-01') })));
142
+ fetcher.searchCommits
143
+ .onCall(0)
144
+ .resolves(
145
+ new Array(100).fill(0).map(() => ({ createdAt: new Date('2022-03-01') }))
146
+ );
147
+ fetcher.searchCommits
148
+ .onCall(1)
149
+ .resolves(
150
+ new Array(5).fill(0).map(() => ({ createdAt: new Date('2022-02-01') }))
151
+ );
152
+ fetcher.searchCommits
153
+ .onCall(2)
154
+ .resolves(
155
+ new Array(5).fill(0).map(() => ({ createdAt: new Date('2022-01-01') }))
156
+ );
131
157
 
132
158
  await github.gather(commitConfig);
133
159
  t.deepEqual(fetcher.searchCommits.getCall(0).args[0], {
@@ -179,22 +205,24 @@ test.serial('should format commits', async (t) => {
179
205
  },
180
206
  };
181
207
 
182
- fetcher.searchCommits.onCall(0).resolves([{
183
- html_url: 'https://github.com/contribution-test/foo',
184
- commit: {
185
- author: {
186
- date: new Date('2022-03-02'),
208
+ fetcher.searchCommits.onCall(0).resolves([
209
+ {
210
+ html_url: 'https://github.com/contribution-test/foo',
211
+ commit: {
212
+ author: {
213
+ date: new Date('2022-03-02'),
214
+ },
215
+ message: 'Test Commit Message',
216
+ },
217
+ repository: {
218
+ private: false,
219
+ name: 'foo',
220
+ owner: {
221
+ login: 'contribution-test',
222
+ },
187
223
  },
188
- message: 'Test Commit Message',
189
- },
190
- repository: {
191
- private: false,
192
- name: 'foo',
193
- owner: {
194
- login: 'contribution-test',
195
- }
196
224
  },
197
- }]);
225
+ ]);
198
226
 
199
227
  const result = await github.gather(commitConfig);
200
228
  t.is(result.length, 1);
@@ -221,22 +249,24 @@ test.serial('should format commits with custom type', async (t) => {
221
249
  },
222
250
  };
223
251
 
224
- fetcher.searchCommits.onCall(0).resolves([{
225
- html_url: 'https://github.com/contribution-test/foo',
226
- commit: {
227
- author: {
228
- date: new Date('2022-03-02'),
252
+ fetcher.searchCommits.onCall(0).resolves([
253
+ {
254
+ html_url: 'https://github.com/contribution-test/foo',
255
+ commit: {
256
+ author: {
257
+ date: new Date('2022-03-02'),
258
+ },
259
+ message: 'Test Commit Message',
260
+ },
261
+ repository: {
262
+ private: false,
263
+ name: 'foo',
264
+ owner: {
265
+ login: 'contribution-test',
266
+ },
229
267
  },
230
- message: 'Test Commit Message',
231
- },
232
- repository: {
233
- private: false,
234
- name: 'foo',
235
- owner: {
236
- login: 'contribution-test',
237
- }
238
268
  },
239
- }]);
269
+ ]);
240
270
 
241
271
  const result = await github.gather(commitConfig);
242
272
  t.is(result.length, 1);
@@ -254,22 +284,24 @@ test.serial('should format private commit', async (t) => {
254
284
  },
255
285
  };
256
286
 
257
- fetcher.searchCommits.onCall(0).resolves([{
258
- html_url: 'https://github.com/contribution-test/foo',
259
- commit: {
260
- author: {
261
- date: new Date('2022-03-02'),
287
+ fetcher.searchCommits.onCall(0).resolves([
288
+ {
289
+ html_url: 'https://github.com/contribution-test/foo',
290
+ commit: {
291
+ author: {
292
+ date: new Date('2022-03-02'),
293
+ },
294
+ message: 'Test Commit Message',
295
+ },
296
+ repository: {
297
+ private: true,
298
+ name: 'foo',
299
+ owner: {
300
+ login: 'contribution-test',
301
+ },
262
302
  },
263
- message: 'Test Commit Message',
264
- },
265
- repository: {
266
- private: true,
267
- name: 'foo',
268
- owner: {
269
- login: 'contribution-test',
270
- }
271
303
  },
272
- }]);
304
+ ]);
273
305
 
274
306
  const result = await github.gather(commitConfig);
275
307
  t.is(result.length, 1);
@@ -287,23 +319,25 @@ test.serial('should ignore commits from before the stopDate', async (t) => {
287
319
  },
288
320
  };
289
321
 
290
- fetcher.searchCommits.onCall(0).resolves([{
291
- html_url: 'https://github.com/contribution-test/foo',
292
- commit: {
293
- author: {
294
- // Old commit
295
- date: new Date('1999-03-02'),
322
+ fetcher.searchCommits.onCall(0).resolves([
323
+ {
324
+ html_url: 'https://github.com/contribution-test/foo',
325
+ commit: {
326
+ author: {
327
+ // Old commit
328
+ date: new Date('1999-03-02'),
329
+ },
330
+ message: 'Test Commit Message',
331
+ },
332
+ repository: {
333
+ private: false,
334
+ name: 'foo',
335
+ owner: {
336
+ login: 'contribution-test',
337
+ },
296
338
  },
297
- message: 'Test Commit Message',
298
- },
299
- repository: {
300
- private: false,
301
- name: 'foo',
302
- owner: {
303
- login: 'contribution-test',
304
- }
305
339
  },
306
- }]);
340
+ ]);
307
341
 
308
342
  const result = await github.gather(commitConfig);
309
343
  t.is(result.length, 0);
@@ -320,22 +354,24 @@ test.serial('should ignore commits not matching filter', async (t) => {
320
354
  },
321
355
  };
322
356
 
323
- fetcher.searchCommits.onCall(0).resolves([{
324
- html_url: 'https://github.com/not-going-to-match-filter/foo',
325
- commit: {
326
- author: {
327
- date: new Date('2022-03-02'),
357
+ fetcher.searchCommits.onCall(0).resolves([
358
+ {
359
+ html_url: 'https://github.com/not-going-to-match-filter/foo',
360
+ commit: {
361
+ author: {
362
+ date: new Date('2022-03-02'),
363
+ },
364
+ message: 'Test Commit Message',
365
+ },
366
+ repository: {
367
+ private: false,
368
+ name: 'foo',
369
+ owner: {
370
+ login: 'contribution-test',
371
+ },
328
372
  },
329
- message: 'Test Commit Message',
330
- },
331
- repository: {
332
- private: false,
333
- name: 'foo',
334
- owner: {
335
- login: 'contribution-test',
336
- }
337
373
  },
338
- }]);
374
+ ]);
339
375
 
340
376
  const result = await github.gather(commitConfig);
341
377
  t.is(result.length, 0);
@@ -353,9 +389,21 @@ test.serial('should fetch issues until stop date', async (t) => {
353
389
  // We want to fetch 2 pages for the first period, and one page for the subsequent periods.
354
390
  // We expect 3 periods to be queried based on the passed stopDate and the faked clock.
355
391
  fetcher.searchIssues.resolves([]);
356
- fetcher.searchIssues.onCall(0).resolves(new Array(100).fill(0).map(() => ({ createdAt: new Date('2022-03-01') })));
357
- fetcher.searchIssues.onCall(1).resolves(new Array(5).fill(0).map(() => ({ createdAt: new Date('2022-02-01') })));
358
- fetcher.searchIssues.onCall(2).resolves(new Array(5).fill(0).map(() => ({ createdAt: new Date('2022-01-01') })));
392
+ fetcher.searchIssues
393
+ .onCall(0)
394
+ .resolves(
395
+ new Array(100).fill(0).map(() => ({ createdAt: new Date('2022-03-01') }))
396
+ );
397
+ fetcher.searchIssues
398
+ .onCall(1)
399
+ .resolves(
400
+ new Array(5).fill(0).map(() => ({ createdAt: new Date('2022-02-01') }))
401
+ );
402
+ fetcher.searchIssues
403
+ .onCall(2)
404
+ .resolves(
405
+ new Array(5).fill(0).map(() => ({ createdAt: new Date('2022-01-01') }))
406
+ );
359
407
 
360
408
  await github.gather(commitConfig);
361
409
  t.deepEqual(fetcher.searchIssues.getCall(0).args[0], {
@@ -407,11 +455,13 @@ test.serial('should format issues', async (t) => {
407
455
  },
408
456
  };
409
457
 
410
- fetcher.searchIssues.onCall(0).resolves([{
411
- html_url: 'https://github.com/contribution-test/foo',
412
- created_at: new Date('2022-03-02'),
413
- title: 'IssueA',
414
- }]);
458
+ fetcher.searchIssues.onCall(0).resolves([
459
+ {
460
+ html_url: 'https://github.com/contribution-test/foo',
461
+ created_at: new Date('2022-03-02'),
462
+ title: 'IssueA',
463
+ },
464
+ ]);
415
465
 
416
466
  const result = await github.gather(commitConfig);
417
467
  t.is(result.length, 1);
@@ -438,11 +488,13 @@ test.serial('should format issues with custom type', async (t) => {
438
488
  },
439
489
  };
440
490
 
441
- fetcher.searchIssues.onCall(0).resolves([{
442
- html_url: 'https://github.com/contribution-test/foo',
443
- created_at: new Date('2022-03-02'),
444
- title: 'IssueA',
445
- }]);
491
+ fetcher.searchIssues.onCall(0).resolves([
492
+ {
493
+ html_url: 'https://github.com/contribution-test/foo',
494
+ created_at: new Date('2022-03-02'),
495
+ title: 'IssueA',
496
+ },
497
+ ]);
446
498
 
447
499
  const result = await github.gather(commitConfig);
448
500
  t.is(result.length, 1);
@@ -460,14 +512,16 @@ test.serial('should format issues (PR)', async (t) => {
460
512
  },
461
513
  };
462
514
 
463
- fetcher.searchIssues.onCall(0).resolves([{
464
- html_url: 'https://github.com/contribution-test/foo',
465
- created_at: new Date('2022-03-02'),
466
- title: 'PR',
467
- pull_request: {
468
- url: 'https://api.github.com/some-pr-url'
515
+ fetcher.searchIssues.onCall(0).resolves([
516
+ {
517
+ html_url: 'https://github.com/contribution-test/foo',
518
+ created_at: new Date('2022-03-02'),
519
+ title: 'PR',
520
+ pull_request: {
521
+ url: 'https://api.github.com/some-pr-url',
522
+ },
469
523
  },
470
- }]);
524
+ ]);
471
525
 
472
526
  const result = await github.gather(commitConfig);
473
527
  t.is(result.length, 1);
@@ -494,14 +548,16 @@ test.serial('should format issues (PR) with custom type', async (t) => {
494
548
  },
495
549
  };
496
550
 
497
- fetcher.searchIssues.onCall(0).resolves([{
498
- html_url: 'https://github.com/contribution-test/foo',
499
- created_at: new Date('2022-03-02'),
500
- title: 'PR',
501
- pull_request: {
502
- url: 'https://api.github.com/some-pr-url'
551
+ fetcher.searchIssues.onCall(0).resolves([
552
+ {
553
+ html_url: 'https://github.com/contribution-test/foo',
554
+ created_at: new Date('2022-03-02'),
555
+ title: 'PR',
556
+ pull_request: {
557
+ url: 'https://api.github.com/some-pr-url',
558
+ },
503
559
  },
504
- }]);
560
+ ]);
505
561
 
506
562
  const result = await github.gather(commitConfig);
507
563
  t.is(result.length, 1);
@@ -519,12 +575,14 @@ test.serial('should ignore issues from before the stopDate', async (t) => {
519
575
  },
520
576
  };
521
577
 
522
- fetcher.searchIssues.onCall(0).resolves([{
523
- html_url: 'https://github.com/contribution-test/foo',
524
- // Old issue
525
- created_at: new Date('1999-01-01'),
526
- title: 'IssueA',
527
- }]);
578
+ fetcher.searchIssues.onCall(0).resolves([
579
+ {
580
+ html_url: 'https://github.com/contribution-test/foo',
581
+ // Old issue
582
+ created_at: new Date('1999-01-01'),
583
+ title: 'IssueA',
584
+ },
585
+ ]);
528
586
 
529
587
  const result = await github.gather(commitConfig);
530
588
  t.is(result.length, 0);
@@ -541,11 +599,13 @@ test.serial('should ignore issues not matching filter', async (t) => {
541
599
  },
542
600
  };
543
601
 
544
- fetcher.searchIssues.onCall(0).resolves([{
545
- html_url: 'https://github.com/not-going-to-match-filter/foo',
546
- created_at: new Date('2022-03-02'),
547
- title: 'IssueA',
548
- }]);
602
+ fetcher.searchIssues.onCall(0).resolves([
603
+ {
604
+ html_url: 'https://github.com/not-going-to-match-filter/foo',
605
+ created_at: new Date('2022-03-02'),
606
+ title: 'IssueA',
607
+ },
608
+ ]);
549
609
 
550
610
  const result = await github.gather(commitConfig);
551
611
  t.is(result.length, 0);
@@ -563,38 +623,46 @@ test.serial('should fetch reviews until stop date', async (t) => {
563
623
  // We want to fetch 2 pages for the first period, and one page for the subsequent periods.
564
624
  // We expect 3 periods to be queried based on the passed stopDate and the faked clock.
565
625
  fetcher.searchIssues.resolves([]);
566
- fetcher.searchIssues.onCall(0).resolves(new Array(100).fill(0).map(() => ({
567
- createdAt: new Date('2022-03-01'),
568
- repository_url: 'https://api.github.com/repos/contributions-test/foo',
569
- number: 1111, // This would be dynamic, but fine enough for this test
570
- pull_request: {
571
- url: 'https://github.com/contributions-test/foo/pulls/1',
572
- },
573
- })));
574
- fetcher.searchIssues.onCall(1).resolves(new Array(5).fill(0).map(() => ({
575
- createdAt: new Date('2022-02-01'),
576
- repository_url: 'https://api.github.com/repos/contributions-test/foo',
577
- number: 1111,
578
- pull_request: {
579
- url: 'https://github.com/contributions-test/foo/pulls/1',
580
- },
581
- })));
582
- fetcher.searchIssues.onCall(2).resolves(new Array(5).fill(0).map(() => ({
583
- createdAt: new Date('2022-01-01'),
584
- repository_url: 'https://api.github.com/repos/contributions-test/foo',
585
- number: 1111,
586
- pull_request: {
587
- url: 'https://github.com/contributions-test/foo/pulls/1',
588
- },
589
- })));
626
+ fetcher.searchIssues.onCall(0).resolves(
627
+ new Array(100).fill(0).map(() => ({
628
+ createdAt: new Date('2022-03-01'),
629
+ repository_url: 'https://api.github.com/repos/contributions-test/foo',
630
+ number: 1111, // This would be dynamic, but fine enough for this test
631
+ pull_request: {
632
+ url: 'https://github.com/contributions-test/foo/pulls/1',
633
+ },
634
+ }))
635
+ );
636
+ fetcher.searchIssues.onCall(1).resolves(
637
+ new Array(5).fill(0).map(() => ({
638
+ createdAt: new Date('2022-02-01'),
639
+ repository_url: 'https://api.github.com/repos/contributions-test/foo',
640
+ number: 1111,
641
+ pull_request: {
642
+ url: 'https://github.com/contributions-test/foo/pulls/1',
643
+ },
644
+ }))
645
+ );
646
+ fetcher.searchIssues.onCall(2).resolves(
647
+ new Array(5).fill(0).map(() => ({
648
+ createdAt: new Date('2022-01-01'),
649
+ repository_url: 'https://api.github.com/repos/contributions-test/foo',
650
+ number: 1111,
651
+ pull_request: {
652
+ url: 'https://github.com/contributions-test/foo/pulls/1',
653
+ },
654
+ }))
655
+ );
590
656
 
591
657
  fetcher.listReviews.resolves([]);
592
- fetcher.listReviews.onCall(0).resolves([{
593
- createdAt: new Date('2022-03-01'),
594
- user: {
595
- login: commitConfig.github.username,
658
+ fetcher.listReviews.onCall(0).resolves([
659
+ {
660
+ createdAt: new Date('2022-03-01'),
661
+ user: {
662
+ login: commitConfig.github.username,
663
+ },
596
664
  },
597
- }]);
665
+ ]);
598
666
 
599
667
  await github.gather(commitConfig);
600
668
  t.deepEqual(fetcher.searchIssues.getCall(0).args[0], {
@@ -652,42 +720,48 @@ test.serial('should format reviews', async (t) => {
652
720
  },
653
721
  };
654
722
 
655
- fetcher.searchIssues.onCall(0).resolves([{
656
- createdAt: new Date('2022-03-02'),
657
- repository_url: 'https://api.github.com/repos/contribution-test/foo',
658
- html_url: 'https://api.github.com/repos/contribution-test/foo',
659
- title: 'Some PR',
660
- number: 1111,
661
- pull_request: {
662
- url: 'https://github.com/contributions-test/foo/pulls/1',
663
- },
664
- }]);
665
-
666
- fetcher.listReviews.onCall(0).resolves([{
667
- submitted_at: new Date('2022-03-02'),
668
- pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
669
- html_url: 'https://github.com/contribution-test/foo/pulls/1',
670
- state: 'CHANGES_REQUESTED',
671
- user: {
672
- login: commitConfig.github.username,
673
- },
674
- }, {
675
- submitted_at: new Date('2022-03-02'),
676
- pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
677
- html_url: 'https://github.com/contribution-test/foo/pulls/1',
678
- state: 'COMMENTED',
679
- user: {
680
- login: commitConfig.github.username,
681
- },
682
- }, {
683
- submitted_at: new Date('2022-03-02'),
684
- pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
685
- html_url: 'https://github.com/contribution-test/foo/pulls/1',
686
- state: 'APPROVED',
687
- user: {
688
- login: commitConfig.github.username,
689
- },
690
- }]);
723
+ fetcher.searchIssues.onCall(0).resolves([
724
+ {
725
+ createdAt: new Date('2022-03-02'),
726
+ repository_url: 'https://api.github.com/repos/contribution-test/foo',
727
+ html_url: 'https://api.github.com/repos/contribution-test/foo',
728
+ title: 'Some PR',
729
+ number: 1111,
730
+ pull_request: {
731
+ url: 'https://github.com/contributions-test/foo/pulls/1',
732
+ },
733
+ },
734
+ ]);
735
+
736
+ fetcher.listReviews.onCall(0).resolves([
737
+ {
738
+ submitted_at: new Date('2022-03-02'),
739
+ pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
740
+ html_url: 'https://github.com/contribution-test/foo/pulls/1',
741
+ state: 'CHANGES_REQUESTED',
742
+ user: {
743
+ login: commitConfig.github.username,
744
+ },
745
+ },
746
+ {
747
+ submitted_at: new Date('2022-03-02'),
748
+ pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
749
+ html_url: 'https://github.com/contribution-test/foo/pulls/1',
750
+ state: 'COMMENTED',
751
+ user: {
752
+ login: commitConfig.github.username,
753
+ },
754
+ },
755
+ {
756
+ submitted_at: new Date('2022-03-02'),
757
+ pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
758
+ html_url: 'https://github.com/contribution-test/foo/pulls/1',
759
+ state: 'APPROVED',
760
+ user: {
761
+ login: commitConfig.github.username,
762
+ },
763
+ },
764
+ ]);
691
765
 
692
766
  const result = await github.gather(commitConfig);
693
767
  t.is(result.length, 3);
@@ -726,46 +800,52 @@ test.serial('should custom format reviews', async (t) => {
726
800
  commentedPR: 'COMMENT!',
727
801
  changesRequestedPR: 'CHANGE!',
728
802
  approvedPR: 'APPROVE!',
729
- }
803
+ },
730
804
  },
731
805
  };
732
806
 
733
- fetcher.searchIssues.onCall(0).resolves([{
734
- createdAt: new Date('2022-03-02'),
735
- repository_url: 'https://api.github.com/repos/contribution-test/foo',
736
- html_url: 'https://api.github.com/repos/contribution-test/foo',
737
- title: 'Some PR',
738
- number: 1111,
739
- pull_request: {
740
- url: 'https://github.com/contributions-test/foo/pulls/1',
741
- },
742
- }]);
743
-
744
- fetcher.listReviews.onCall(0).resolves([{
745
- submitted_at: new Date('2022-03-02'),
746
- pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
747
- html_url: 'https://github.com/contribution-test/foo/pulls/1',
748
- state: 'CHANGES_REQUESTED',
749
- user: {
750
- login: commitConfig.github.username,
751
- },
752
- }, {
753
- submitted_at: new Date('2022-03-02'),
754
- pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
755
- html_url: 'https://github.com/contribution-test/foo/pulls/1',
756
- state: 'COMMENTED',
757
- user: {
758
- login: commitConfig.github.username,
759
- },
760
- }, {
761
- submitted_at: new Date('2022-03-02'),
762
- pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
763
- html_url: 'https://github.com/contribution-test/foo/pulls/1',
764
- state: 'APPROVED',
765
- user: {
766
- login: commitConfig.github.username,
767
- },
768
- }]);
807
+ fetcher.searchIssues.onCall(0).resolves([
808
+ {
809
+ createdAt: new Date('2022-03-02'),
810
+ repository_url: 'https://api.github.com/repos/contribution-test/foo',
811
+ html_url: 'https://api.github.com/repos/contribution-test/foo',
812
+ title: 'Some PR',
813
+ number: 1111,
814
+ pull_request: {
815
+ url: 'https://github.com/contributions-test/foo/pulls/1',
816
+ },
817
+ },
818
+ ]);
819
+
820
+ fetcher.listReviews.onCall(0).resolves([
821
+ {
822
+ submitted_at: new Date('2022-03-02'),
823
+ pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
824
+ html_url: 'https://github.com/contribution-test/foo/pulls/1',
825
+ state: 'CHANGES_REQUESTED',
826
+ user: {
827
+ login: commitConfig.github.username,
828
+ },
829
+ },
830
+ {
831
+ submitted_at: new Date('2022-03-02'),
832
+ pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
833
+ html_url: 'https://github.com/contribution-test/foo/pulls/1',
834
+ state: 'COMMENTED',
835
+ user: {
836
+ login: commitConfig.github.username,
837
+ },
838
+ },
839
+ {
840
+ submitted_at: new Date('2022-03-02'),
841
+ pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
842
+ html_url: 'https://github.com/contribution-test/foo/pulls/1',
843
+ state: 'APPROVED',
844
+ user: {
845
+ login: commitConfig.github.username,
846
+ },
847
+ },
848
+ ]);
769
849
 
770
850
  const result = await github.gather(commitConfig);
771
851
  t.is(result.length, 3);
@@ -785,23 +865,27 @@ test.serial('should ignore reviews from before the stopDate', async (t) => {
785
865
  },
786
866
  };
787
867
 
788
- fetcher.searchIssues.onCall(0).resolves([{
789
- createdAt: new Date('1999-01-01'),
790
- repository_url: 'https://api.github.com/repos/contribution-test/foo',
791
- html_url: 'https://api.github.com/repos/contribution-test/foo',
792
- title: 'Some PR',
793
- number: 1111,
794
- pull_request: {
795
- url: 'https://github.com/contributions-test/foo/pulls/1',
868
+ fetcher.searchIssues.onCall(0).resolves([
869
+ {
870
+ createdAt: new Date('1999-01-01'),
871
+ repository_url: 'https://api.github.com/repos/contribution-test/foo',
872
+ html_url: 'https://api.github.com/repos/contribution-test/foo',
873
+ title: 'Some PR',
874
+ number: 1111,
875
+ pull_request: {
876
+ url: 'https://github.com/contributions-test/foo/pulls/1',
877
+ },
796
878
  },
797
- }]);
879
+ ]);
798
880
 
799
- fetcher.listReviews.onCall(0).resolves([{
800
- submitted_at: new Date('1999-01-01'),
801
- pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
802
- html_url: 'https://github.com/contribution-test/foo/pulls/1',
803
- state: 'CHANGES_REQUESTED',
804
- }]);
881
+ fetcher.listReviews.onCall(0).resolves([
882
+ {
883
+ submitted_at: new Date('1999-01-01'),
884
+ pull_request_url: 'https://github.com/contributions-test/foo/pulls/1',
885
+ html_url: 'https://github.com/contribution-test/foo/pulls/1',
886
+ state: 'CHANGES_REQUESTED',
887
+ },
888
+ ]);
805
889
 
806
890
  const result = await github.gather(commitConfig);
807
891
  t.is(result.length, 0);
@@ -818,23 +902,27 @@ test.serial('should ignore reviews not matching filter', async (t) => {
818
902
  },
819
903
  };
820
904
 
821
- fetcher.searchIssues.onCall(0).resolves([{
822
- createdAt: new Date('2022-03-02'),
823
- repository_url: 'https://api.github.com/repos/not-matching-filter/foo',
824
- html_url: 'https://api.github.com/repos/not-matching-filter/foo',
825
- title: 'Some PR',
826
- number: 1111,
827
- pull_request: {
828
- url: 'https://github.com/not-matching-filter/foo/pulls/1',
829
- },
830
- }]);
831
-
832
- fetcher.listReviews.onCall(0).resolves([{
833
- submitted_at: new Date('2022-03-01'),
834
- pull_request_url: 'https://github.com/not-matching-filter/foo/pulls/1',
835
- html_url: 'https://github.com/not-matching-filter/foo/pulls/1',
836
- state: 'CHANGES_REQUESTED',
837
- }]);
905
+ fetcher.searchIssues.onCall(0).resolves([
906
+ {
907
+ createdAt: new Date('2022-03-02'),
908
+ repository_url: 'https://api.github.com/repos/not-matching-filter/foo',
909
+ html_url: 'https://api.github.com/repos/not-matching-filter/foo',
910
+ title: 'Some PR',
911
+ number: 1111,
912
+ pull_request: {
913
+ url: 'https://github.com/not-matching-filter/foo/pulls/1',
914
+ },
915
+ },
916
+ ]);
917
+
918
+ fetcher.listReviews.onCall(0).resolves([
919
+ {
920
+ submitted_at: new Date('2022-03-01'),
921
+ pull_request_url: 'https://github.com/not-matching-filter/foo/pulls/1',
922
+ html_url: 'https://github.com/not-matching-filter/foo/pulls/1',
923
+ state: 'CHANGES_REQUESTED',
924
+ },
925
+ ]);
838
926
 
839
927
  const result = await github.gather(commitConfig);
840
928
  t.is(result.length, 0);
@@ -851,42 +939,48 @@ test.serial('should ignore reviews not by user', async (t) => {
851
939
  },
852
940
  };
853
941
 
854
- fetcher.searchIssues.onCall(0).resolves([{
855
- createdAt: new Date('2022-03-02'),
856
- repository_url: 'https://api.github.com/repos/contribution-test/foo',
857
- html_url: 'https://api.github.com/repos/contribution-test/foo',
858
- title: 'Some PR',
859
- number: 1111,
860
- pull_request: {
861
- url: 'https://github.com/contribution-test/foo/pulls/1',
862
- },
863
- }]);
864
-
865
- fetcher.listReviews.onCall(0).resolves([{
866
- submitted_at: new Date('2022-03-01'),
867
- pull_request_url: 'https://github.com/contribution-test/foo/pulls/1',
868
- html_url: 'https://github.com/contribution-test/foo/pulls/1',
869
- state: 'CHANGES_REQUESTED',
870
- user: {
871
- login: 'not-the-right-user',
872
- },
873
- }, {
874
- submitted_at: new Date('2022-03-01'),
875
- pull_request_url: 'https://github.com/contribution-test/foo/pulls/1',
876
- html_url: 'https://github.com/contribution-test/foo/pulls/1',
877
- state: 'COMMENTED',
878
- user: {
879
- login: 'not-the-right-user',
880
- },
881
- }, {
882
- submitted_at: new Date('2022-03-01'),
883
- pull_request_url: 'https://github.com/contribution-test/foo/pulls/1',
884
- html_url: 'https://github.com/contribution-test/foo/pulls/1',
885
- state: 'CHANGES_REQUESTED',
886
- user: {
887
- login: commitConfig.github.username,
888
- },
889
- }]);
942
+ fetcher.searchIssues.onCall(0).resolves([
943
+ {
944
+ createdAt: new Date('2022-03-02'),
945
+ repository_url: 'https://api.github.com/repos/contribution-test/foo',
946
+ html_url: 'https://api.github.com/repos/contribution-test/foo',
947
+ title: 'Some PR',
948
+ number: 1111,
949
+ pull_request: {
950
+ url: 'https://github.com/contribution-test/foo/pulls/1',
951
+ },
952
+ },
953
+ ]);
954
+
955
+ fetcher.listReviews.onCall(0).resolves([
956
+ {
957
+ submitted_at: new Date('2022-03-01'),
958
+ pull_request_url: 'https://github.com/contribution-test/foo/pulls/1',
959
+ html_url: 'https://github.com/contribution-test/foo/pulls/1',
960
+ state: 'CHANGES_REQUESTED',
961
+ user: {
962
+ login: 'not-the-right-user',
963
+ },
964
+ },
965
+ {
966
+ submitted_at: new Date('2022-03-01'),
967
+ pull_request_url: 'https://github.com/contribution-test/foo/pulls/1',
968
+ html_url: 'https://github.com/contribution-test/foo/pulls/1',
969
+ state: 'COMMENTED',
970
+ user: {
971
+ login: 'not-the-right-user',
972
+ },
973
+ },
974
+ {
975
+ submitted_at: new Date('2022-03-01'),
976
+ pull_request_url: 'https://github.com/contribution-test/foo/pulls/1',
977
+ html_url: 'https://github.com/contribution-test/foo/pulls/1',
978
+ state: 'CHANGES_REQUESTED',
979
+ user: {
980
+ login: commitConfig.github.username,
981
+ },
982
+ },
983
+ ]);
890
984
 
891
985
  const result = await github.gather(commitConfig);
892
986
  t.is(result.length, 1);
@@ -905,32 +999,40 @@ test.serial('should fetch comments until stop date', async (t) => {
905
999
  // We want to fetch 2 pages for the first period, and one page for the subsequent periods.
906
1000
  // We expect 3 periods to be queried based on the passed stopDate and the faked clock.
907
1001
  fetcher.searchIssues.resolves([]);
908
- fetcher.searchIssues.onCall(0).resolves(new Array(100).fill(0).map(() => ({
909
- createdAt: new Date('2022-03-01'),
910
- repository_url: 'https://api.github.com/repos/contribution-test/foo',
911
- number: 1111, // This would be dynamic, but fine enough for this test
912
- title: 'IssueTitle',
913
- })));
914
- fetcher.searchIssues.onCall(1).resolves(new Array(5).fill(0).map(() => ({
915
- createdAt: new Date('2022-02-01'),
916
- repository_url: 'https://api.github.com/repos/contribution-test/foo',
917
- number: 1111,
918
- title: 'IssueTitle',
919
- })));
920
- fetcher.searchIssues.onCall(2).resolves(new Array(5).fill(0).map(() => ({
921
- createdAt: new Date('2022-01-01'),
922
- repository_url: 'https://api.github.com/repos/contribution-test/foo',
923
- number: 1111,
924
- title: 'IssueTitle',
925
- })));
1002
+ fetcher.searchIssues.onCall(0).resolves(
1003
+ new Array(100).fill(0).map(() => ({
1004
+ createdAt: new Date('2022-03-01'),
1005
+ repository_url: 'https://api.github.com/repos/contribution-test/foo',
1006
+ number: 1111, // This would be dynamic, but fine enough for this test
1007
+ title: 'IssueTitle',
1008
+ }))
1009
+ );
1010
+ fetcher.searchIssues.onCall(1).resolves(
1011
+ new Array(5).fill(0).map(() => ({
1012
+ createdAt: new Date('2022-02-01'),
1013
+ repository_url: 'https://api.github.com/repos/contribution-test/foo',
1014
+ number: 1111,
1015
+ title: 'IssueTitle',
1016
+ }))
1017
+ );
1018
+ fetcher.searchIssues.onCall(2).resolves(
1019
+ new Array(5).fill(0).map(() => ({
1020
+ createdAt: new Date('2022-01-01'),
1021
+ repository_url: 'https://api.github.com/repos/contribution-test/foo',
1022
+ number: 1111,
1023
+ title: 'IssueTitle',
1024
+ }))
1025
+ );
926
1026
 
927
1027
  fetcher.listComments.resolves([]);
928
- fetcher.listComments.onCall(0).resolves([{
929
- createdAt: new Date('2022-03-01'),
930
- user: {
931
- login: config.github.username,
1028
+ fetcher.listComments.onCall(0).resolves([
1029
+ {
1030
+ createdAt: new Date('2022-03-01'),
1031
+ user: {
1032
+ login: config.github.username,
1033
+ },
932
1034
  },
933
- }]);
1035
+ ]);
934
1036
 
935
1037
  await github.gather(commitConfig);
936
1038
  t.deepEqual(fetcher.searchIssues.getCall(0).args[0], {
@@ -990,23 +1092,28 @@ test.serial('should format comments', async (t) => {
990
1092
  },
991
1093
  };
992
1094
 
993
- fetcher.searchIssues.onCall(0).resolves([{
994
- createdAt: new Date('2022-03-02'),
995
- repository_url: 'https://api.github.com/repos/contribution-test/foo',
996
- url: 'https://api.github.com/repos/contribution-test/foo/issues/1111',
997
- html_url: 'https://github.com/contribution-test/foo/issues/1111',
998
- title: 'Some Issue',
999
- number: 1111,
1000
- }]);
1001
-
1002
- fetcher.listComments.onCall(0).resolves([{
1003
- created_at: new Date('2022-03-02'),
1004
- issue_url: 'https://api.github.com/repos/contribution-test/foo/issues/1111',
1005
- html_url: 'https://github.com/contribution-test/foo/issues/1111',
1006
- user: {
1007
- login: config.github.username,
1008
- },
1009
- }]);
1095
+ fetcher.searchIssues.onCall(0).resolves([
1096
+ {
1097
+ createdAt: new Date('2022-03-02'),
1098
+ repository_url: 'https://api.github.com/repos/contribution-test/foo',
1099
+ url: 'https://api.github.com/repos/contribution-test/foo/issues/1111',
1100
+ html_url: 'https://github.com/contribution-test/foo/issues/1111',
1101
+ title: 'Some Issue',
1102
+ number: 1111,
1103
+ },
1104
+ ]);
1105
+
1106
+ fetcher.listComments.onCall(0).resolves([
1107
+ {
1108
+ created_at: new Date('2022-03-02'),
1109
+ issue_url:
1110
+ 'https://api.github.com/repos/contribution-test/foo/issues/1111',
1111
+ html_url: 'https://github.com/contribution-test/foo/issues/1111',
1112
+ user: {
1113
+ login: config.github.username,
1114
+ },
1115
+ },
1116
+ ]);
1010
1117
 
1011
1118
  const result = await github.gather(commitConfig);
1012
1119
  t.is(result.length, 1);
@@ -1034,23 +1141,28 @@ test.serial('should custom format comments', async (t) => {
1034
1141
  },
1035
1142
  };
1036
1143
 
1037
- fetcher.searchIssues.onCall(0).resolves([{
1038
- createdAt: new Date('2022-03-02'),
1039
- repository_url: 'https://api.github.com/repos/contribution-test/foo',
1040
- url: 'https://api.github.com/repos/contribution-test/foo/issues/1111',
1041
- html_url: 'https://github.com/contribution-test/foo/issues/1111',
1042
- title: 'Some Issue',
1043
- number: 1111,
1044
- }]);
1045
-
1046
- fetcher.listComments.onCall(0).resolves([{
1047
- created_at: new Date('2022-03-02'),
1048
- issue_url: 'https://api.github.com/repos/contribution-test/foo/issues/1111',
1049
- html_url: 'https://github.com/contribution-test/foo/issues/1111',
1050
- user: {
1051
- login: config.github.username,
1052
- },
1053
- }]);
1144
+ fetcher.searchIssues.onCall(0).resolves([
1145
+ {
1146
+ createdAt: new Date('2022-03-02'),
1147
+ repository_url: 'https://api.github.com/repos/contribution-test/foo',
1148
+ url: 'https://api.github.com/repos/contribution-test/foo/issues/1111',
1149
+ html_url: 'https://github.com/contribution-test/foo/issues/1111',
1150
+ title: 'Some Issue',
1151
+ number: 1111,
1152
+ },
1153
+ ]);
1154
+
1155
+ fetcher.listComments.onCall(0).resolves([
1156
+ {
1157
+ created_at: new Date('2022-03-02'),
1158
+ issue_url:
1159
+ 'https://api.github.com/repos/contribution-test/foo/issues/1111',
1160
+ html_url: 'https://github.com/contribution-test/foo/issues/1111',
1161
+ user: {
1162
+ login: config.github.username,
1163
+ },
1164
+ },
1165
+ ]);
1054
1166
 
1055
1167
  const result = await github.gather(commitConfig);
1056
1168
  t.is(result.length, 1);
@@ -1069,23 +1181,28 @@ test.serial('should ignore comments from before stopDate', async (t) => {
1069
1181
  },
1070
1182
  };
1071
1183
 
1072
- fetcher.searchIssues.onCall(0).resolves([{
1073
- createdAt: new Date('2022-03-02'),
1074
- repository_url: 'https://api.github.com/repos/contribution-test/foo',
1075
- url: 'https://api.github.com/repos/contribution-test/foo/issues/1111',
1076
- html_url: 'https://github.com/contribution-test/foo/issues/1111',
1077
- title: 'Some Issue',
1078
- number: 1111,
1079
- }]);
1080
-
1081
- fetcher.listComments.onCall(0).resolves([{
1082
- created_at: new Date('1999-01-01'),
1083
- issue_url: 'https://api.github.com/repos/contribution-test/foo/issues/1111',
1084
- html_url: 'https://github.com/contribution-test/foo/issues/1111',
1085
- user: {
1086
- login: config.github.username,
1087
- },
1088
- }]);
1184
+ fetcher.searchIssues.onCall(0).resolves([
1185
+ {
1186
+ createdAt: new Date('2022-03-02'),
1187
+ repository_url: 'https://api.github.com/repos/contribution-test/foo',
1188
+ url: 'https://api.github.com/repos/contribution-test/foo/issues/1111',
1189
+ html_url: 'https://github.com/contribution-test/foo/issues/1111',
1190
+ title: 'Some Issue',
1191
+ number: 1111,
1192
+ },
1193
+ ]);
1194
+
1195
+ fetcher.listComments.onCall(0).resolves([
1196
+ {
1197
+ created_at: new Date('1999-01-01'),
1198
+ issue_url:
1199
+ 'https://api.github.com/repos/contribution-test/foo/issues/1111',
1200
+ html_url: 'https://github.com/contribution-test/foo/issues/1111',
1201
+ user: {
1202
+ login: config.github.username,
1203
+ },
1204
+ },
1205
+ ]);
1089
1206
 
1090
1207
  const result = await github.gather(commitConfig);
1091
1208
  t.is(result.length, 0);
@@ -1103,32 +1220,38 @@ test.serial('should ignore comments not matching filter', async (t) => {
1103
1220
  },
1104
1221
  };
1105
1222
 
1106
- fetcher.searchIssues.onCall(0).resolves([{
1107
- createdAt: new Date('2022-03-02'),
1108
- repository_url: 'https://api.github.com/repos/not-matching-filter/foo',
1109
- url: 'https://api.github.com/repos/not-matching-filter/foo/issues/1111',
1110
- html_url: 'https://github.com/not-matching-filter/foo/issues/1111',
1111
- title: 'Some Issue',
1112
- number: 1111,
1113
- }, {
1114
- createdAt: new Date('2022-03-02'),
1115
- repository_url: 'https://api.github.com/repos/contribution-test/foo',
1116
- url: 'https://api.github.com/repos/contribution-test/foo/issues/1111',
1117
- html_url: 'https://github.com/contribution-test/foo/issues/1111',
1118
- title: 'Some Issue',
1119
- number: 1111,
1120
- }]);
1223
+ fetcher.searchIssues.onCall(0).resolves([
1224
+ {
1225
+ createdAt: new Date('2022-03-02'),
1226
+ repository_url: 'https://api.github.com/repos/not-matching-filter/foo',
1227
+ url: 'https://api.github.com/repos/not-matching-filter/foo/issues/1111',
1228
+ html_url: 'https://github.com/not-matching-filter/foo/issues/1111',
1229
+ title: 'Some Issue',
1230
+ number: 1111,
1231
+ },
1232
+ {
1233
+ createdAt: new Date('2022-03-02'),
1234
+ repository_url: 'https://api.github.com/repos/contribution-test/foo',
1235
+ url: 'https://api.github.com/repos/contribution-test/foo/issues/1111',
1236
+ html_url: 'https://github.com/contribution-test/foo/issues/1111',
1237
+ title: 'Some Issue',
1238
+ number: 1111,
1239
+ },
1240
+ ]);
1121
1241
 
1122
1242
  // While this is the first call, it will be the call for the second issue
1123
1243
  // as we filter out the first issue from above due to not matching,.
1124
- fetcher.listComments.onCall(0).resolves([{
1125
- created_at: new Date('2022-03-02'),
1126
- issue_url: 'https://api.github.com/repos/not-matching-filter/foo/issues/1111',
1127
- html_url: 'https://github.com/not-matching-filter/foo/issues/1111',
1128
- user: {
1129
- login: config.github.username,
1130
- },
1131
- }]);
1244
+ fetcher.listComments.onCall(0).resolves([
1245
+ {
1246
+ created_at: new Date('2022-03-02'),
1247
+ issue_url:
1248
+ 'https://api.github.com/repos/not-matching-filter/foo/issues/1111',
1249
+ html_url: 'https://github.com/not-matching-filter/foo/issues/1111',
1250
+ user: {
1251
+ login: config.github.username,
1252
+ },
1253
+ },
1254
+ ]);
1132
1255
 
1133
1256
  const result = await github.gather(commitConfig);
1134
1257
  t.is(result.length, 0);