Skip to content

Commit

Permalink
Merge pull request #89 from Actyx/ada/tweak-test-for-actual
Browse files Browse the repository at this point in the history
tweak test code of actual
  • Loading branch information
Kelerchian authored Jan 25, 2024
2 parents f51bde4 + 5121d18 commit 2899508
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions machine-runner/tests/esm/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,18 @@ describe('machine as async generator', () => {
let resolved = false
const actualPromise = machine.actual()
actualPromise.finally(() => (resolved = true))

// ensures that the above actualPrimomise.finally callback is executed
// immediately IF actualPromise is a resolved promise this guarantee is
// enforced by this specification
// https://tc39.es/ecma262/multipage/executable-code-and-execution-contexts.html#sec-hostenqueuepromisejob
// saying that reactions (then, catch, finally callbacks) are executed in
// the order they are registered and since the await below is registered
// after the actualPromise.finally callback, the control flow will
// continue also after the finally callback is executed, which is
// important because the line below inspect the value of `resolved`
await Promise.resolve()

expect(resolved).toBe(false)

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

0 comments on commit 2899508

Please sign in to comment.