forked from zloirock/core-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes.promise.finally.js
39 lines (36 loc) · 1.21 KB
/
es.promise.finally.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
35
36
37
38
39
import Promise from 'core-js-pure/features/promise';
QUnit.test('Promise#finally', assert => {
assert.isFunction(Promise.prototype.finally);
assert.arity(Promise.prototype.finally, 1);
assert.nonEnumerable(Promise.prototype, 'finally');
assert.ok(Promise.resolve(42).finally(() => { /* empty */ }) instanceof Promise, 'returns a promise');
});
QUnit.test('Promise#finally, resolved', assert => {
assert.expect(3);
const async = assert.async();
let called = 0;
let argument = null;
Promise.resolve(42).finally(it => {
called++;
argument = it;
}).then(it => {
assert.same(it, 42, 'resolved with a correct value');
assert.same(called, 1, 'onFinally function called one time');
assert.same(argument, undefined, 'onFinally function called with a correct argument');
async();
});
});
QUnit.test('Promise#finally, rejected', assert => {
assert.expect(2);
const async = assert.async();
let called = 0;
let argument = null;
Promise.reject(42).finally(it => {
called++;
argument = it;
}).catch(() => {
assert.same(called, 1, 'onFinally function called one time');
assert.same(argument, undefined, 'onFinally function called with a correct argument');
async();
});
});