From 03bf600c0ea8bd2cc25d1e13e1e8e39bae26a7a5 Mon Sep 17 00:00:00 2001 From: "Lasse R.H. Nielsen" Date: Fri, 4 Mar 2022 15:27:02 +0100 Subject: [PATCH] Update test to not assume completion happens synchronously. --- test/cancelable_operation_test.dart | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/cancelable_operation_test.dart b/test/cancelable_operation_test.dart index fa41001..cf2fd8b 100644 --- a/test/cancelable_operation_test.dart +++ b/test/cancelable_operation_test.dart @@ -421,12 +421,12 @@ void main() { }); group('original operation canceled', () { - test('onCancel not set', () { + test('onCancel not set', () async { onCancel = null; final operation = runThen(); - expect(originalCompleter.operation.cancel(), completes); + await expectLater(originalCompleter.operation.cancel(), completes); expect(operation.isCanceled, true); }); @@ -460,8 +460,10 @@ void main() { var operation = runThen(); var workCompleter = Completer(); originalCompleter.complete(workCompleter.future); - originalCompleter.operation.cancel(); + var cancelation = originalCompleter.operation.cancel(); + expect(originalCompleter.isCanceled, true); workCompleter.complete(0); + await cancelation; expect(operation.isCanceled, true); await workCompleter.future; });