| 1 |
"use strict"; |
| 2 |
|
| 3 |
const actual = []; |
| 4 |
const expected = ["foo", "bar", "baz", "xyz"]; |
| 5 |
|
| 6 |
const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); |
| 7 |
|
| 8 |
async function* test() { |
| 9 |
yield await delay(0).then(() => actual.push("foo")); |
| 10 |
await delay(0).then(() => actual.push("bar")); |
| 11 |
yield delay(0).then(() => actual.push("baz")); |
| 12 |
actual.push("xyz"); |
| 13 |
} |
| 14 |
|
| 15 |
async function main() { |
| 16 |
const g = test(); |
| 17 |
g.next(); |
| 18 |
g.next(); |
| 19 |
await g.next(); |
| 20 |
} |
| 21 |
|
| 22 |
return main().then(() => { |
| 23 |
expect(actual).toEqual(expected); |
| 24 |
}); |