feat: export toPromise and toValue, see #158

This commit is contained in:
harttle
2020-08-05 00:46:01 +08:00
parent 0dbb7792d7
commit 2e5ab98bfc
5 changed files with 33 additions and 17 deletions
+10 -1
View File
@@ -1,10 +1,19 @@
import { toThenable, toValue } from '../../../src/util/async'
import { toThenable, toPromise, toValue } from '../../../src/util/async'
import { expect, use } from 'chai'
import * as chaiAsPromised from 'chai-as-promised'
use(chaiAsPromised)
describe('utils/async', () => {
describe('#toPromise()', function () {
it('should return a promise', async () => {
function * foo () {
return 'foo'
}
const result = await toPromise(foo())
expect(result).to.equal('foo')
})
})
describe('#toThenable()', function () {
it('should support iterable with single return statement', async () => {
function * foo () {