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

Commit 28e32c4

Browse files
vicbchirayuk
authored andcommitted
test(_specs): Add types, follow coding conventions
1 parent 7c997be commit 28e32c4

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

test/_specs.dart

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,15 @@ export 'package:angular/mock/module.dart';
3333
export 'package:perf_api/perf_api.dart';
3434

3535
es(String html) {
36-
var div = new DivElement();
37-
div.setInnerHtml(html, treeSanitizer: new NullTreeSanitizer());
36+
var div = new DivElement()..setInnerHtml(html, treeSanitizer: new NullTreeSanitizer());
3837
return new List.from(div.nodes);
3938
}
4039

4140
e(String html) => es(html).first;
4241

43-
4442
Expect expect(actual, [matcher]) {
4543
final expect = new Expect(actual);
46-
if (matcher != null) {
47-
expect.to(matcher);
48-
}
44+
if (matcher != null) expect.to(matcher);
4945
return expect;
5046
}
5147

@@ -54,54 +50,65 @@ class Expect extends gns.Expect {
5450

5551
NotExpect get not => new NotExpect(actual);
5652

57-
toBeValid() => _expect(actual.valid && !actual.invalid, true,
58-
reason: 'Form is not valid');
53+
void toBeValid() => _expect(actual.valid && !actual.invalid, true, reason: 'Form is not valid');
5954

60-
toBePristine() => _expect(actual.pristine && !actual.dirty, true,
61-
reason: 'Form is dirty');
55+
void toBePristine() => _expect(actual.pristine && !actual.dirty, true, reason: 'Form is dirty');
6256

63-
get _expect => gns.guinness.matchers.expect;
57+
Function get _expect => gns.guinness.matchers.expect;
6458
}
6559

6660
class NotExpect extends gns.NotExpect {
6761
NotExpect(actual) : super(actual);
6862

69-
toBeValid() => _expect(actual.valid && !actual.invalid, false,
70-
reason: 'Form is valid');
63+
void toBeValid() => _expect(actual.valid && !actual.invalid, false, reason: 'Form is valid');
7164

72-
toBePristine() => _expect(actual.pristine && !actual.dirty, false,
73-
reason: 'Form is pristine');
65+
void toBePristine() => _expect(actual.pristine && !actual.dirty, false, reason: 'Form is pristine');
7466

75-
get _expect => gns.guinness.matchers.expect;
67+
Function get _expect => gns.guinness.matchers.expect;
7668
}
7769

7870

79-
_injectify(fn) {
71+
Function _injectify(Function fn) {
8072
// The function does two things:
8173
// First: if the it() passed a function, we wrap it in
8274
// the "sync" FunctionComposition.
8375
// Second: when we are calling the FunctionComposition,
8476
// we inject "inject" into the middle of the
8577
// composition.
8678
if (fn is! FunctionComposition) fn = sync(fn);
87-
return fn.outer(inject(fn.inner));
79+
var fc = fn as FunctionComposition;
80+
return fc.outer(inject(fc.inner));
8881
}
8982

9083
// Replace guinness syntax elements to inject dependencies.
91-
beforeEachModule(fn) => gns.beforeEach(module(fn), priority:1);
92-
beforeEach(fn) => gns.beforeEach(_injectify(fn));
93-
afterEach(fn) => gns.afterEach(_injectify(fn));
94-
it(name, fn) => gns.it(name, _injectify(fn));
95-
iit(name, fn) => gns.iit(name, _injectify(fn));
84+
void beforeEachModule(Function fn) {
85+
gns.beforeEach(module(fn), priority:1);
86+
}
87+
88+
void beforeEach(Function fn) {
89+
gns.beforeEach(_injectify(fn));
90+
}
91+
92+
void afterEach(Function fn) {
93+
gns.afterEach(_injectify(fn));
94+
}
95+
96+
void it(String name, Function fn) {
97+
gns.it(name, _injectify(fn));
98+
}
99+
100+
void iit(String name, Function fn) {
101+
gns.iit(name, _injectify(fn));
102+
}
96103

97104
_removeNgBinding(node) {
98105
if (node is Element) {
99-
node = node.clone(true) as Element;
100-
node.classes.remove('ng-binding');
101-
node.querySelectorAll(".ng-binding").forEach((Element e) {
106+
var el = node.clone(true) as Element;
107+
el.classes.remove('ng-binding');
108+
el.querySelectorAll(".ng-binding").forEach((Element e) {
102109
e.classes.remove('ng-binding');
103110
});
104-
return node;
111+
return el;
105112
}
106113
return node;
107114
}

0 commit comments

Comments
 (0)