Simplify handling of promises as values.
This commit is contained in:
parent
cdfb4655b5
commit
58fe68f1c4
2 changed files with 8 additions and 16 deletions
|
@ -455,13 +455,12 @@ describe(`Channel object`, function() {
|
|||
it(`allows promises to be sent through a channel`, function() {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
process.once(`unhandledRejection`, reject);
|
||||
const channel = Channel();
|
||||
|
||||
const channel = Channel.of(
|
||||
Promise.resolve(`resolved`),
|
||||
new Promise((resolve, reject) => {
|
||||
setImmediate(reject, new Error(`rejected`));
|
||||
})
|
||||
);
|
||||
(async () => {
|
||||
await channel.push(Promise.resolve(`resolved`));
|
||||
await channel.push(Promise.reject(new Error(`rejected`)));
|
||||
})();
|
||||
|
||||
assert.equal(await channel.shift(), `resolved`);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue