Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
fix(jasmine syntax): Drop the wrapFn concept and let _specs.dart hand…
Browse files Browse the repository at this point in the history
…le the sync wrapper
  • Loading branch information
jbdeboer committed Mar 14, 2014
1 parent 53aeb4a commit 1e971e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
16 changes: 13 additions & 3 deletions test/_specs.dart
Expand Up @@ -245,10 +245,21 @@ class JQuery extends DelegatingList<Node> {
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));
Expand All @@ -262,7 +273,6 @@ var jasmine = jasmine_syntax.jasmine;


main() {
jasmine_syntax.wrapFn(sync);
jasmine_syntax.beforeEach(setUpInjector, priority:3);
jasmine_syntax.afterEach(tearDownInjector);
}
16 changes: 2 additions & 14 deletions test/jasmine_syntax.dart
Expand Up @@ -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]));
Expand All @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 1e971e6

Please sign in to comment.