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