diff --git a/addon/src/-private/scheduler.ts b/addon/src/-private/scheduler.ts index cb224507..4f1d73a7 100644 --- a/addon/src/-private/scheduler.ts +++ b/addon/src/-private/scheduler.ts @@ -238,6 +238,7 @@ class MicroRoutine { } stop() { this.stopped = true; + this.resolve({ stopped: true }); if (this.state && isPromise(this.state.value)) { fireCancellation(this.state.value); } diff --git a/test-app/tests/unit/scheduler-test.js b/test-app/tests/unit/scheduler-test.js index b1dc6448..87987e45 100644 --- a/test-app/tests/unit/scheduler-test.js +++ b/test-app/tests/unit/scheduler-test.js @@ -274,7 +274,7 @@ module('Unit | scheduler', function (hooks) { }); test('promise returned from spawn does not resolve if an inner promise resolves after stop', function (assert) { - assert.expect(1); + assert.expect(2); return spawn(function* () { spawn(function* () { @@ -284,8 +284,11 @@ module('Unit | scheduler', function (hooks) { }); stop(task); resolve(); - yield task; - assert.ok(false, 'should never get here'); + let yielded = yield task; + assert.ok( + yielded.stopped, + 'After stopping a Microtask it should yield `{ stopped: true }`.', + ); }); yield microwait(); assert.ok(true, 'got to end');