@@ -77,6 +77,13 @@ describe("searchCode", () => {
7777
7878// ─── fetchAllResults ──────────────────────────────────────────────────────────
7979
80+ const makeFetchItem = ( i : number ) => ( {
81+ path : `src/file${ i } .ts` ,
82+ html_url : `https://github.com/org/repo/blob/main/src/file${ i } .ts` ,
83+ repository : { full_name : "org/repo" , archived : false } ,
84+ text_matches : [ ] ,
85+ } ) ;
86+
8087describe ( "fetchAllResults" , ( ) => {
8188 afterEach ( ( ) => {
8289 globalThis . fetch = originalFetch ;
@@ -180,12 +187,6 @@ describe("fetchAllResults", () => {
180187 } ) ;
181188
182189 it ( "fetches multiple pages until total is reached" , async ( ) => {
183- const makeItem = ( i : number ) => ( {
184- path : `src/file${ i } .ts` ,
185- html_url : `https://github.com/org/repo/blob/main/src/file${ i } .ts` ,
186- repository : { full_name : "org/repo" , archived : false } ,
187- text_matches : [ ] ,
188- } ) ;
189190 let searchPage = 0 ;
190191 globalThis . fetch = ( async ( url : string | URL | Request ) => {
191192 const urlStr = url . toString ( ) ;
@@ -195,8 +196,8 @@ describe("fetchAllResults", () => {
195196 searchPage ++ ;
196197 const items =
197198 searchPage === 1
198- ? Array . from ( { length : 2 } , ( _ , i ) => makeItem ( i ) )
199- : Array . from ( { length : 1 } , ( _ , i ) => makeItem ( 2 + i ) ) ;
199+ ? Array . from ( { length : 2 } , ( _ , i ) => makeFetchItem ( i ) )
200+ : Array . from ( { length : 1 } , ( _ , i ) => makeFetchItem ( 2 + i ) ) ;
200201 return new Response ( JSON . stringify ( { items, total_count : 3 } ) , {
201202 status : 200 ,
202203 headers : { "content-type" : "application/json" } ,
0 commit comments