Add docs and tests for getOctokit script context

This commit is contained in:
Salman Chishti
2026-03-09 04:44:59 -07:00
committed by GitHub
parent a7dc0e4fc1
commit cc685dce52
3 changed files with 24 additions and 0 deletions

View File

@@ -8,6 +8,18 @@ describe('callAsyncFunction', () => {
expect(result).toEqual('bar')
})
test('passes getOctokit through the script context', async () => {
const getOctokit = jest.fn().mockReturnValue('secondary-client')
const result = await callAsyncFunction(
{getOctokit} as any,
"return getOctokit('token')"
)
expect(getOctokit).toHaveBeenCalledWith('token')
expect(result).toEqual('secondary-client')
})
test('throws on ReferenceError', async () => {
expect.assertions(1)