diff --git a/test/_specs.dart b/test/_specs.dart index c61289b0e..c488246dc 100644 --- a/test/_specs.dart +++ b/test/_specs.dart @@ -245,10 +245,21 @@ class JQuery extends DelegatingList { shadowRoot() => new JQuery((this[0] as Element).shadowRoot); } +_injectify(fn) { + // The function does two things: + // First: if the it() passed a function, we wrap it in + // the "sync" FunctionComposition. + // Second: when we are calling the FuncitonComposition, + // we inject "inject" into the middle of the + // composition. + if (fn is! FunctionComposition) { + fn = sync(fn); + } + return fn.outer(inject(fn.inner)); +} + // Jasmine syntax -_injectify(fn) => fn is FunctionComposition ? fn.outer(inject(fn.inner)) : inject(fn); beforeEachModule(fn) => jasmine_syntax.beforeEach(module(fn), priority:1); - beforeEach(fn) => jasmine_syntax.beforeEach(_injectify(fn)); afterEach(fn) => jasmine_syntax.afterEach(_injectify(fn)); it(name, fn) => jasmine_syntax.it(name, _injectify(fn)); @@ -262,7 +273,6 @@ var jasmine = jasmine_syntax.jasmine; main() { - jasmine_syntax.wrapFn(sync); jasmine_syntax.beforeEach(setUpInjector, priority:3); jasmine_syntax.afterEach(tearDownInjector); } diff --git a/test/jasmine_syntax.dart b/test/jasmine_syntax.dart index d4f06aabb..d50b8fb62 100644 --- a/test/jasmine_syntax.dart +++ b/test/jasmine_syntax.dart @@ -3,16 +3,6 @@ library jasmine; import 'package:unittest/unittest.dart' as unit; import 'package:angular/utils.dart' as utils; -Function _wrapFn; - -_maybeWrapFn(fn) => () { - if (_wrapFn != null) { - _wrapFn(fn)(); - } else { - fn(); - } -}; - var _beforeEachFnsForCurrentTest = []; _withSetup(fn) => () { _beforeEachFnsForCurrentTest.sort((a, b) => Comparable.compare(b[1], a[1])); @@ -24,8 +14,8 @@ _withSetup(fn) => () { } }; -it(name, fn) => unit.test(name, _withSetup(_maybeWrapFn(fn))); -iit(name, fn) => unit.solo_test(name, _withSetup(_maybeWrapFn(fn))); +it(name, fn) => unit.test(name, _withSetup(fn)); +iit(name, fn) => unit.solo_test(name, _withSetup(fn)); xit(name, fn) {} xdescribe(name, fn) {} ddescribe(name, fn) => describe(name, fn, true); @@ -77,8 +67,6 @@ describe(name, fn, [bool exclusive=false]) { beforeEach(fn, {priority: 0}) => currentDescribe.beforeEachFns.add([fn, priority]); afterEach(fn) => currentDescribe.afterEachFns.insert(0, fn); -wrapFn(fn) => _wrapFn = fn; - var jasmine = new Jasmine(); class SpyFunctionInvocationResult {