-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
30 lines (25 loc) · 771 Bytes
/
test.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
const chai = require('chai')
const chaiAsPromised = require('chai-as-promised')
chai.should()
chai.use(chaiAsPromised)
require('.')
describe('Promise#finally', function () {
it('should resolve to the settled value', function () {
return Promise
.resolve('ok')
.finally(() => 'finally')
.then(value => value.should.equal('ok'))
})
it('should resolve to the thrown error', function () {
return Promise
.reject(new Error('error'))
.finally(() => 'finally').should.be.rejectedWith('error')
})
it('should overwrite thrown error if finally fails', function () {
return Promise
.reject(new Error('error'))
.finally(() => {
throw new Error('finally')
}).should.be.rejectedWith('finally')
})
})