2014-10-23 19:58:31 +02:00
|
|
|
// Copyright 2014 Cubane Canada, Inc. All rights reserved.
|
|
|
|
// See LICENSE for details.
|
|
|
|
|
|
|
|
/*---
|
2018-01-05 18:26:51 +01:00
|
|
|
info: |
|
2014-10-23 19:58:31 +02:00
|
|
|
Promise.all with 1-element array
|
|
|
|
should accept an array with settled promise
|
2015-02-10 22:01:39 +01:00
|
|
|
es6id: S25.4.4.1_A7.2_T1
|
2014-10-23 19:58:31 +02:00
|
|
|
author: Sam Mikes
|
|
|
|
description: Promise.all() accepts a one-element array
|
2017-06-23 17:06:32 +02:00
|
|
|
includes: [promiseHelper.js]
|
2016-02-12 18:59:51 +01:00
|
|
|
flags: [async]
|
2014-10-23 19:58:31 +02:00
|
|
|
---*/
|
|
|
|
|
|
|
|
var sequence = [];
|
|
|
|
|
2018-02-15 21:11:21 +01:00
|
|
|
var p1 = new Promise(function(resolve) {
|
|
|
|
resolve({});
|
|
|
|
});
|
2014-10-23 19:58:31 +02:00
|
|
|
|
|
|
|
sequence.push(1);
|
|
|
|
|
2018-02-15 21:11:21 +01:00
|
|
|
Promise.all([p1]).then(function(resolved) {
|
|
|
|
sequence.push(4);
|
2020-06-24 21:18:35 +02:00
|
|
|
assert.sameValue(sequence.length, 4);
|
2018-02-15 21:11:21 +01:00
|
|
|
checkSequence(sequence, "Expected Promise.all().then to queue second");
|
2014-10-23 19:58:31 +02:00
|
|
|
}).catch($DONE);
|
|
|
|
|
2018-02-15 21:11:21 +01:00
|
|
|
p1.then(function() {
|
|
|
|
sequence.push(3);
|
2020-06-24 21:18:35 +02:00
|
|
|
assert.sameValue(sequence.length, 3);
|
2018-02-15 21:11:21 +01:00
|
|
|
checkSequence(sequence, "Expected p1.then to queue first");
|
|
|
|
}).then(function() {
|
|
|
|
sequence.push(5);
|
2020-06-24 21:18:35 +02:00
|
|
|
assert.sameValue(sequence.length, 5);
|
2018-02-15 21:11:21 +01:00
|
|
|
checkSequence(sequence, "Expected final then to queue last");
|
2014-10-23 19:58:31 +02:00
|
|
|
}).then($DONE, $DONE);
|
|
|
|
|
|
|
|
sequence.push(2);
|