Skip to content

Commit 17a3cc2

Browse files
simpsonwCopilot
andauthored
fix: mock pagination return
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent b7fe25b commit 17a3cc2

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

src/main.test.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -360,19 +360,36 @@ describe('main() auto-pass integration', () => {
360360
})
361361

362362
// Mock github.getOctokit to return empty results (all checks passing)
363+
const mockRepos = {
364+
getCombinedStatusForRef: jest.fn()
365+
}
366+
const mockChecks = {
367+
listForRef: jest.fn()
368+
}
363369
const mockOctokit = {
364370
paginate: {
365-
iterator: jest.fn().mockReturnValue((async function* () {
366-
yield {data: {statuses: []}}
367-
})())
371+
iterator: jest.fn().mockImplementation((endpoint: any, _params: any) => {
372+
// Paginated combined status responses
373+
if (endpoint === mockRepos.getCombinedStatusForRef) {
374+
return (async function* () {
375+
yield { data: { statuses: [] } }
376+
})()
377+
}
378+
// Paginated check run responses
379+
if (endpoint === mockChecks.listForRef) {
380+
return (async function* () {
381+
yield { data: [] }
382+
})()
383+
}
384+
// Default: empty array-shaped data
385+
return (async function* () {
386+
yield { data: [] }
387+
})()
388+
})
368389
},
369390
rest: {
370-
repos: {
371-
getCombinedStatusForRef: jest.fn()
372-
},
373-
checks: {
374-
listForRef: jest.fn()
375-
}
391+
repos: mockRepos,
392+
checks: mockChecks
376393
}
377394
}
378395
jest.spyOn(github, 'getOctokit').mockReturnValue(mockOctokit as any)

0 commit comments

Comments
 (0)