Skip to content

Commit

Permalink
Use async/await
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Apr 28, 2019
1 parent d0dedd7 commit 6399e06
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions test/force-promise.test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
let forcePromise = require('../force-promise')

it('executes Promise', () => {
return forcePromise(() => Promise.resolve('result')).then(result => {
expect(result).toEqual('result')
})
it('executes Promise', async () => {
let result = await forcePromise(() => Promise.resolve('result'))
expect(result).toEqual('result')
})

it('executes sync function', async () => {
let result = await forcePromise(() => 'result')
expect(result).toEqual('result')
})

it('sends Promises error', () => {
expect.assertions(1)
let error = new Error()
return forcePromise(() => Promise.resolve().then(() => {
return forcePromise(async () => {
throw error
})).catch(e => {
}).catch(e => {
expect(e).toBe(error)
})
})

it('executes sync function', () => {
return forcePromise(() => 'result').then(result => {
expect(result).toEqual('result')
})
})

it('sends sync error', () => {
expect.assertions(1)
let error = new Error()
return forcePromise(() => {
throw error
Expand Down

0 comments on commit 6399e06

Please sign in to comment.