Add tests for the AsyncFunction

This commit is contained in:
Jonathan Clem
2020-02-27 17:27:49 -05:00
parent 6eefe48bc9
commit 38e3ffe4c6
7 changed files with 4679 additions and 100 deletions

View 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')
})
})