@@ -5,7 +5,7 @@ import { beforeEach, expect, it, vi } from 'vitest';
55
66vi . mock ( '../../github/core' , ( ) => ( {
77 GitHub : vi . fn ( ) . mockImplementation ( ( ) => ( {
8- api : { issues : { listForRepo : vi . fn ( ) } } ,
8+ api : { paginate : vi . fn ( ) , issues : { listForRepo : vi . fn ( ) } } ,
99 ownerAndRepo : { owner : 'test-owner' , repo : 'test-repo' } ,
1010 configuredLabels : [ 'label1' , 'label2' ] ,
1111 } ) ) ,
@@ -18,32 +18,28 @@ beforeEach(() => {
1818} ) ;
1919
2020it ( 'Should return an empty array when there are no issues' , async ( ) => {
21- ( mockGitHub . api . issues . listForRepo as any ) . mockResolvedValue ( {
22- data : [ ] ,
23- } ) ;
21+ ( mockGitHub . api . paginate as any ) . mockResolvedValue ( [ ] ) ;
2422
2523 const result = await GetOpenedIssuesModule . getOpenedIssues ( mockGitHub ) ;
2624
2725 expect ( result ) . toEqual ( [ ] ) ;
2826} ) ;
2927
3028it ( 'Issues with only different labels from the configuration or without body should be filtered out' , async ( ) => {
31- ( mockGitHub . api . issues . listForRepo as any ) . mockResolvedValue ( {
32- data : [
33- {
34- number : 1 ,
35- body : 'body' ,
36- labels : [ { name : 'other-label' } ] ,
37- created_at : '2023-01-01T12:00:00Z' ,
38- } ,
39- {
40- number : 2 ,
41- body : undefined ,
42- labels : [ 'label1' , 'label2' ] ,
43- created_at : '2023-01-01T12:00:00Z' ,
44- } ,
45- ] ,
46- } ) ;
29+ ( mockGitHub . api . paginate as any ) . mockResolvedValue ( [
30+ {
31+ number : 1 ,
32+ body : 'body' ,
33+ labels : [ { name : 'other-label' } ] ,
34+ created_at : '2023-01-01T12:00:00Z' ,
35+ } ,
36+ {
37+ number : 2 ,
38+ body : undefined ,
39+ labels : [ 'label1' , 'label2' ] ,
40+ created_at : '2023-01-01T12:00:00Z' ,
41+ } ,
42+ ] ) ;
4743
4844 const result = await GetOpenedIssuesModule . getOpenedIssues ( mockGitHub ) ;
4945
@@ -53,21 +49,19 @@ it('Issues with only different labels from the configuration or without body sho
5349it ( 'Should return only issues that have all configured labels' , async ( ) => {
5450 const EXPECTED_HASH = 'abcd123' ;
5551
56- ( mockGitHub . api . issues . listForRepo as any ) . mockResolvedValue ( {
57- data : [
58- {
59- number : 1 ,
60- body : `https://github.com/org/name/commit/${ EXPECTED_HASH } ` ,
61- created_at : '2023-01-01T12:00:00Z' ,
62- labels : [
63- 'label1' ,
64- { name : 'label2' } ,
65- { name : undefined } ,
66- 'extra-label' ,
67- ] ,
68- } ,
52+ ( mockGitHub . api . paginate as any ) . mockResolvedValue ( [
53+ {
54+ number : 1 ,
55+ body : `https://github.com/org/name/commit/${ EXPECTED_HASH } ` ,
56+ created_at : '2023-01-01T12:00:00Z' ,
57+ labels : [
58+ 'label1' ,
59+ { name : 'label2' } ,
60+ { name : undefined } ,
61+ 'extra-label' ,
6962 ] ,
70- } ) ;
63+ } ,
64+ ] ) ;
7165
7266 const result = await GetOpenedIssuesModule . getOpenedIssues ( mockGitHub ) ;
7367
@@ -83,22 +77,20 @@ it('Should return only issues that have all configured labels', async () => {
8377it ( 'Issues without a hash should be filtered out' , async ( ) => {
8478 const EXPECTED_HASH = 'abcd123' ;
8579
86- ( mockGitHub . api . issues . listForRepo as any ) . mockResolvedValue ( {
87- data : [
88- {
89- number : 1 ,
90- body : `https://github.com/org/repo/commit/${ EXPECTED_HASH } ` ,
91- created_at : '2023-01-01T12:00:00Z' ,
92- labels : [ { name : 'label1' } , { name : 'label2' } ] ,
93- } ,
94- {
95- number : 2 ,
96- body : 'Issue body without hash' ,
97- created_at : '2023-01-01T12:00:00Z' ,
98- labels : [ { name : 'label1' } , { name : 'label2' } ] ,
99- } ,
100- ] ,
101- } ) ;
80+ ( mockGitHub . api . paginate as any ) . mockResolvedValue ( [
81+ {
82+ number : 1 ,
83+ body : `https://github.com/org/repo/commit/${ EXPECTED_HASH } ` ,
84+ created_at : '2023-01-01T12:00:00Z' ,
85+ labels : [ { name : 'label1' } , { name : 'label2' } ] ,
86+ } ,
87+ {
88+ number : 2 ,
89+ body : 'Issue body without hash' ,
90+ created_at : '2023-01-01T12:00:00Z' ,
91+ labels : [ { name : 'label1' } , { name : 'label2' } ] ,
92+ } ,
93+ ] ) ;
10294
10395 const result = await GetOpenedIssuesModule . getOpenedIssues ( mockGitHub ) ;
10496
0 commit comments