@@ -25,60 +25,50 @@ class BarComponent {
25
25
26
26
main () {
27
27
describe ('EventHandler' , () {
28
- Element ngAppElement;
29
28
beforeEachModule ((Module module) {
30
- ngAppElement = new DivElement ()..attributes['ng-app' ] = '' ;
31
- module..bind (FooController );
32
- module..bind (BarComponent );
33
- module..bind (Node , toValue: ngAppElement);
34
- document.body.append (ngAppElement);
29
+ module..bind (FooController )
30
+ ..bind (BarComponent );
35
31
});
36
32
37
- afterEach (() {
38
- ngAppElement.remove ();
39
- ngAppElement = null ;
40
- });
41
-
42
- compile (_, html) {
43
- ngAppElement.setInnerHtml (html, treeSanitizer: new NullTreeSanitizer ());
44
- _.compile (ngAppElement);
45
- return ngAppElement.firstChild;
46
- }
47
33
48
- it ('should register and handle event' , (TestBed _) {
49
- var e = compile (_,
34
+ it ('should register and handle event' , (TestBed _, Application app ) {
35
+ var e = _. compile (
50
36
'''<div foo>
51
- <div on-abc="ctrl.invoked=true; "></div>
37
+ <div on-abc="ctrl.invoked=true"></div>
52
38
</div>''' );
39
+ document.body.append (app.element..append (e));
53
40
54
41
_.triggerEvent (e.querySelector ('[on-abc]' ), 'abc' );
55
42
expect (_.getScope (e).context['ctrl' ].invoked).toEqual (true );
56
43
});
57
44
58
- it ('shoud register and handle event with long name' , (TestBed _) {
59
- var e = compile (_,
45
+ it ('shoud register and handle event with long name' , (TestBed _, Application app ) {
46
+ var e = _. compile (
60
47
'''<div foo>
61
- <div on-my-new-event="ctrl.invoked=true; "></div>
48
+ <div on-my-new-event="ctrl.invoked=true"></div>
62
49
</div>''' );
50
+ document.body.append (app.element..append (e));
63
51
64
52
_.triggerEvent (e.querySelector ('[on-my-new-event]' ), 'myNewEvent' );
65
53
var fooScope = _.getScope (e);
66
54
expect (fooScope.context['ctrl' ].invoked).toEqual (true );
67
55
});
68
56
69
- it ('shoud have model updates applied correctly' , (TestBed _) {
70
- var e = compile (_,
57
+ it ('should have model updates applied correctly' , (TestBed _, Application app ) {
58
+ var e = _. compile (
71
59
'''<div foo>
72
- <div on-abc='ctrl.description="new description"; '>{{ctrl.description}}</div>
60
+ <div on-abc='ctrl.description="new description"'>{{ctrl.description}}</div>
73
61
</div>''' );
62
+ document.body.append (app.element..append (e));
74
63
var el = document.querySelector ('[on-abc]' );
75
64
el.dispatchEvent (new Event ('abc' ));
76
65
_.rootScope.apply ();
77
66
expect (el.text).toEqual ("new description" );
78
67
});
79
68
80
- it ('shoud register event when shadow dom is used' , async ((TestBed _) {
81
- var e = compile (_,'<bar></bar>' );
69
+ it ('should register event when shadow dom is used' , async ((TestBed _, Application app) {
70
+ var e = _.compile ('<bar></bar>' );
71
+ document.body.append (app.element..append (e));
82
72
83
73
microLeap ();
84
74
@@ -89,13 +79,14 @@ main() {
89
79
expect (ctrl.invoked).toEqual (true );
90
80
}));
91
81
92
- it ('shoud handle event within content only once' , async ((TestBed _) {
93
- var e = compile (_,
82
+ it ('shoud handle event within content only once' , async ((TestBed _, Application app ) {
83
+ var e = _. compile (
94
84
'''<div foo>
95
85
<bar>
96
86
<div on-abc="ctrl.invoked=true;"></div>
97
87
</bar>
98
88
</div>''' );
89
+ document.body.append (app.element..append (e));
99
90
100
91
microLeap ();
101
92
0 commit comments