diff --git a/test/jasmine_syntax.dart b/test/jasmine_syntax.dart index 557c3bcce..1e4bb2aa5 100644 --- a/test/jasmine_syntax.dart +++ b/test/jasmine_syntax.dart @@ -4,6 +4,8 @@ import 'package:unittest/unittest.dart' as unit; import 'package:angular/utils.dart' as utils; var _beforeEachFnsForCurrentTest = []; +var _afterEachFnsForCurrentTest = []; + _withSetup(fn) => () { _beforeEachFnsForCurrentTest.sort((a, b) => Comparable.compare(b[1], a[1])); _beforeEachFnsForCurrentTest.forEach((fn) => fn[0]()); @@ -11,9 +13,14 @@ _withSetup(fn) => () { fn(); } finally { _beforeEachFnsForCurrentTest = []; + var _aeFns = _afterEachFnsForCurrentTest; + _afterEachFnsForCurrentTest = []; + _aeFns.reversed.forEach((fn) => fn()); } }; + + it(name, fn) => unit.test(name, _withSetup(fn)); iit(name, fn) => unit.solo_test(name, _withSetup(fn)); xit(name, fn) {} @@ -35,10 +42,7 @@ class Describe { setUp() { _beforeEachFnsForCurrentTest.addAll(beforeEachFns); - } - - tearDown() { - afterEachFns.forEach((fn) => fn()); + _afterEachFnsForCurrentTest.addAll(afterEachFns); } } @@ -55,7 +59,6 @@ describe(name, fn, [bool exclusive=false]) { try { unit.group(name, () { unit.setUp(currentDescribe.setUp); - unit.tearDown(currentDescribe.tearDown); fn(); }); } finally { @@ -147,5 +150,4 @@ class Jasmine { main(){ unit.setUp(currentDescribe.setUp); - unit.tearDown(currentDescribe.tearDown); }