aboutsummaryrefslogtreecommitdiff
path: root/test/js/promise_s01.t.js
blob: acd98d00be5649fe240abb569367bad51000cf09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*---
includes: [compareArray.js]
flags: [async]
---*/

let stages = [];

var promise = new Promise(function(resolve, reject) {
    stages.push('One');

    reject(123);
}).catch((v) => {stages.push(v)});

stages.push('Two');

promise.then(() => {stages.push('Four'); return {num: 'Five'}})
.then(obj => {stages.push(obj.num);  return {num: 'Six'}})
.then(obj => {stages.push(obj.num)})
.then(() => assert.compareArray(stages, ["One", "Two", "Three", 123, "Four", "Five", "Six"]))
.then($DONE, $DONE);

stages.push('Three');