mirror of
https://github.com/actions/github-script.git
synced 2026-03-29 01:15:06 +00:00
Add docs and tests for getOctokit script context
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user