@@ -32,19 +32,15 @@ export 'package:angular/mock/module.dart';
32
32
export 'package:perf_api/perf_api.dart' ;
33
33
34
34
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 ());
37
36
return new List .from (div.nodes);
38
37
}
39
38
40
39
e (String html) => es (html).first;
41
40
42
-
43
41
Expect expect (actual, [matcher]) {
44
42
final expect = new Expect (actual);
45
- if (matcher != null ) {
46
- expect.to (matcher);
47
- }
43
+ if (matcher != null ) expect.to (matcher);
48
44
return expect;
49
45
}
50
46
@@ -53,54 +49,65 @@ class Expect extends gns.Expect {
53
49
54
50
NotExpect get not => new NotExpect (actual);
55
51
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' );
58
53
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' );
61
55
62
- get _expect => gns.guinness.matchers.expect;
56
+ Function get _expect => gns.guinness.matchers.expect;
63
57
}
64
58
65
59
class NotExpect extends gns.NotExpect {
66
60
NotExpect (actual) : super (actual);
67
61
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' );
70
63
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' );
73
65
74
- get _expect => gns.guinness.matchers.expect;
66
+ Function get _expect => gns.guinness.matchers.expect;
75
67
}
76
68
77
69
78
- _injectify (fn) {
70
+ Function _injectify (Function fn) {
79
71
// The function does two things:
80
72
// First: if the it() passed a function, we wrap it in
81
73
// the "sync" FunctionComposition.
82
74
// Second: when we are calling the FunctionComposition,
83
75
// we inject "inject" into the middle of the
84
76
// composition.
85
77
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));
87
80
}
88
81
89
82
// 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
+ }
95
102
96
103
_removeNgBinding (node) {
97
104
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) {
101
108
e.classes.remove ('ng-binding' );
102
109
});
103
- return node ;
110
+ return el ;
104
111
}
105
112
return node;
106
113
}
0 commit comments