Skip to content

Commit 0241d0b

Browse files
vicbDiana Salsbury
authored and
Diana Salsbury
committed
test(_specs): Add types, follow coding conventions
1 parent db26877 commit 0241d0b

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
@@ -32,19 +32,15 @@ export 'package:angular/mock/module.dart';
3232
export 'package:perf_api/perf_api.dart';
3333

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

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

42-
4341
Expect expect(actual, [matcher]) {
4442
final expect = new Expect(actual);
45-
if (matcher != null) {
46-
expect.to(matcher);
47-
}
43+
if (matcher != null) expect.to(matcher);
4844
return expect;
4945
}
5046

@@ -53,54 +49,65 @@ class Expect extends gns.Expect {
5349

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

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

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

62-
get _expect => gns.guinness.matchers.expect;
56+
Function get _expect => gns.guinness.matchers.expect;
6357
}
6458

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

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

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

74-
get _expect => gns.guinness.matchers.expect;
66+
Function get _expect => gns.guinness.matchers.expect;
7567
}
7668

7769

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

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

96103
_removeNgBinding(node) {
97104
if (node is Element) {
98-
node = node.clone(true) as Element;
99-
node.classes.remove('ng-binding');
100-
node.querySelectorAll(".ng-binding").forEach((Element e) {
105+
var el = node.clone(true) as Element;
106+
el.classes.remove('ng-binding');
107+
el.querySelectorAll(".ng-binding").forEach((Element e) {
101108
e.classes.remove('ng-binding');
102109
});
103-
return node;
110+
return el;
104111
}
105112
return node;
106113
}

0 commit comments

Comments
 (0)