-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.spec.js
34 lines (30 loc) · 876 Bytes
/
index.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const am = require('./index')
describe('Runs an async main', () => {
it('runs an async function', done => {
am(async function main() {
done()
})
})
it('runs a sync function', () => {
am(function main() {
expect(true).toEqual(true)
})
})
it('handles error from an async function', done => {
am(async function main() {
throw 'Bad bad bad error!'
}, error => {
expect(error).toEqual('Bad bad bad error!')
expect(process.exitCode).not.toBe(0)
done()
})
})
it('handles error from a sync function', () => {
am(function main() {
throw 'Bad bad bad error!'
}, error => {
expect(error).toEqual('Bad bad bad error!')
expect(process.exitCode).not.toBe(0)
})
})
})