OLD | NEW |
1 library ng_non_bindable_spec; | 1 library ng_non_bindable_spec; |
2 | 2 |
3 import '../_specs.dart'; | 3 import '../_specs.dart'; |
4 | 4 |
5 main() { | 5 main() { |
6 describe('NonBindableDirective', () { | 6 describe('NonBindableDirective', () { |
7 TestBed _; | 7 TestBed _; |
8 | 8 |
9 beforeEach(inject((TestBed tb) => _ = tb)); | 9 beforeEach((TestBed tb) => _ = tb); |
10 | 10 |
11 it('should set ignore all other markup/directives on the descendent nodes', | 11 it('should set ignore all other markup/directives on the descendent nodes', |
12 inject((Scope scope, Injector injector, Compiler compiler, DirectiveMa
p directives) { | 12 (Scope scope, Injector injector, Compiler compiler, DirectiveMap direc
tives) { |
13 var element = $('<div>' + | 13 Element element = e('<div>' + |
14 ' <span id="s1">{{a}}</span>' + | 14 ' <span id="s1">{{a}}</span>' + |
15 ' <span id="s2" ng-bind="b"></span>' + | 15 ' <span id="s2" ng-bind="b"></span>' + |
16 ' <div foo="{{a}}" ng-non-bindable>' + | 16 ' <div foo="{{a}}" ng-non-bindable>' + |
17 ' <span ng-bind="a"></span>{{b}}' + | 17 ' <span ng-bind="a"></span>{{b}}' + |
18 ' </div>' + | 18 ' </div>' + |
19 ' <span id="s3">{{a}}</span>' + | 19 ' <span id="s3">{{a}}</span>' + |
20 ' <span id="s4" ng-bind="b"></span>' + | 20 ' <span id="s4" ng-bind="b"></span>' + |
21 '</div>'); | 21 '</div>'); |
22 compiler(element, directives)(injector, element); | 22 compiler([element], directives)(injector, [element]); |
23 scope.context['a'] = "one"; | 23 scope.context['a'] = "one"; |
24 scope.context['b'] = "two"; | 24 scope.context['b'] = "two"; |
25 scope.apply(); | 25 scope.apply(); |
26 // Bindings not contained by ng-non-bindable should resolve. | 26 // Bindings not contained by ng-non-bindable should resolve. |
27 expect(element.find("#s1").text().trim()).toEqual('one'); | 27 expect(element.querySelector("#s1").text.trim()).toEqual('one'); |
28 expect(element.find("#s2").text().trim()).toEqual('two'); | 28 expect(element.querySelector("#s2").text.trim()).toEqual('two'); |
29 expect(element.find("#s3").text().trim()).toEqual('one'); | 29 expect(element.querySelector("#s3").text.trim()).toEqual('one'); |
30 expect(element.find("#s4").text().trim()).toEqual('two'); | 30 expect(element.querySelector("#s4").text.trim()).toEqual('two'); |
31 // Bindings contained by ng-non-bindable should be left alone. | 31 // Bindings contained by ng-non-bindable should be left alone. |
32 var nonBindableDiv = element.find("div"); | 32 var nonBindableDiv = element.querySelector("div"); |
33 expect(nonBindableDiv.html().trim()).toEqual('<span ng-bind="a"></span>{{b
}}'); | 33 expect(nonBindableDiv).toHaveHtml('<span ng-bind="a"></span>{{b}}'); |
34 expect(nonBindableDiv.text().trim()).toEqual('{{b}}'); | 34 expect(nonBindableDiv.text.trim()).toEqual('{{b}}'); |
35 // Bindings on the same node are processed. | 35 // Bindings on the same node are processed. |
36 expect(nonBindableDiv.attr('foo')).toEqual('one'); | 36 expect(nonBindableDiv.attributes['foo']).toEqual('one'); |
37 })); | 37 }); |
38 }); | 38 }); |
39 } | 39 } |
OLD | NEW |