Skip to content

Commit 5121d18

Browse files
committed
tweak test code of actual
1 parent f51bde4 commit 5121d18

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

machine-runner/tests/esm/runner.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,18 @@ describe('machine as async generator', () => {
611611
let resolved = false
612612
const actualPromise = machine.actual()
613613
actualPromise.finally(() => (resolved = true))
614+
615+
// ensures that the above actualPrimomise.finally callback is executed
616+
// immediately IF actualPromise is a resolved promise this guarantee is
617+
// enforced by this specification
618+
// https://tc39.es/ecma262/multipage/executable-code-and-execution-contexts.html#sec-hostenqueuepromisejob
619+
// saying that reactions (then, catch, finally callbacks) are executed in
620+
// the order they are registered and since the await below is registered
621+
// after the actualPromise.finally callback, the control flow will
622+
// continue also after the finally callback is executed, which is
623+
// important because the line below inspect the value of `resolved`
624+
await Promise.resolve()
625+
614626
expect(resolved).toBe(false)
615627

616628
await r1.toggleCommandDelay({ delaying: false, reject: true })

0 commit comments

Comments
 (0)