diff --git a/test/cancelable_operation_test.dart b/test/cancelable_operation_test.dart index cf2fd8b..6bcadab 100644 --- a/test/cancelable_operation_test.dart +++ b/test/cancelable_operation_test.dart @@ -495,6 +495,48 @@ void main() { expect(originalCompleter.isCanceled, false); }); + + test('onValue callback not called after cancel', () async { + var called = false; + onValue = (_) { + called = true; + fail("onValue unreachable"); + return ""; + }; + + await runThen().cancel(); + originalCompleter.complete(0); + await flushMicrotasks(); + expect(called, false); + }); + + test('onError callback not called after cancel', () async { + var called = false; + onError = (_, __) { + called = true; + fail("onError unreachable"); + return ""; + }; + + await runThen().cancel(); + originalCompleter.completeError("Error", StackTrace.empty); + await flushMicrotasks(); + expect(called, false); + }); + + test('onCancel callback not called after cancel', () async { + var called = false; + onCancel = () { + called = true; + fail("onCancel unreachable"); + return ""; + }; + + await runThen().cancel(); + originalCompleter.complete(0); + await flushMicrotasks(); + expect(called, false); + }); }); });