Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Add regression test.
Browse files Browse the repository at this point in the history
  • Loading branch information
lrhn committed Mar 16, 2022
1 parent c26e7a4 commit c3da3bb
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/cancelable_operation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});

Expand Down

0 comments on commit c3da3bb

Please sign in to comment.