mirror of
https://github.com/actions/github-script.git
synced 2025-12-08 08:06:23 +00:00
Add tests for the AsyncFunction
This commit is contained in:
26
__test__/async-function.test.ts
Normal file
26
__test__/async-function.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import {callAsyncFunction} from '../src/async-function'
|
||||
|
||||
describe('callAsyncFunction', () => {
|
||||
test('calls the function with its arguments', async () => {
|
||||
const result = await callAsyncFunction({foo: 'bar'}, 'return foo')
|
||||
expect(result).toEqual('bar')
|
||||
})
|
||||
|
||||
test('throws on ReferenceError', async () => {
|
||||
expect.assertions(1)
|
||||
|
||||
try {
|
||||
await callAsyncFunction({}, 'proces')
|
||||
} catch (err) {
|
||||
expect(err).toBeInstanceOf(ReferenceError)
|
||||
}
|
||||
})
|
||||
|
||||
test('can access process', async () => {
|
||||
await callAsyncFunction({}, 'process')
|
||||
})
|
||||
|
||||
test('can access console', async () => {
|
||||
await callAsyncFunction({}, 'console')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user