From 8f77efd96f41ff78d358d97e5c301f1c39b5ff24 Mon Sep 17 00:00:00 2001 From: "Lasse R.H. Nielsen" Date: Wed, 16 Mar 2022 13:51:48 +0100 Subject: [PATCH] Add regression test. --- test/cancelable_operation_test.dart | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/cancelable_operation_test.dart b/test/cancelable_operation_test.dart index cf2fd8b..7dc78da 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(); + await originalCompleter.cancel(); + await flushMicrotasks(); + expect(called, false); + }); }); });