From c834837dcb5b9220b1570c7f96785d763a7b0968 Mon Sep 17 00:00:00 2001 From: James deBoer Date: Wed, 12 Mar 2014 09:33:33 -0700 Subject: [PATCH] feat(mock zone): isAsyncQueueEmpty --- lib/mock/zone.dart | 5 +++++ test/mock/zone_spec.dart | 2 ++ 2 files changed, 7 insertions(+) diff --git a/lib/mock/zone.dart b/lib/mock/zone.dart index 862d42014..5eed01db2 100644 --- a/lib/mock/zone.dart +++ b/lib/mock/zone.dart @@ -46,6 +46,11 @@ microLeap() { } } +/** + * Returns whether the async queue is empty. + */ +isAsyncQueueEmpty() => _asyncQueue.isEmpty; + /** * Simulates a clock tick by running any scheduled timers. Can only be used * in [async] tests.Clock tick will call [microLeap] to process the microtask diff --git a/test/mock/zone_spec.dart b/test/mock/zone_spec.dart index e5415b7c1..b1aaf9c83 100644 --- a/test/mock/zone_spec.dart +++ b/test/mock/zone_spec.dart @@ -42,7 +42,9 @@ void main() { async(() { new Future.value('s').then((_) { thenRan = true; }); expect(thenRan).toBe(false); + expect(isAsyncQueueEmpty()).toBe(false); microLeap(); + expect(isAsyncQueueEmpty()).toBe(true); expect(thenRan).toBe(true); ran = true; })();