Skip to content

Commit dc7b764

Browse files
committed
test(ngBindSpec): correct tests + split them up
1 parent 82d90a4 commit dc7b764

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

test/ng/directive/ngBindSpec.js

+31-14
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe('ng-bind-*', function() {
2020
expect(element.text()).toEqual('misko');
2121
}));
2222

23+
2324
it('should set text to blank if undefined', inject(function($rootScope, $compile) {
2425
element = $compile('<div ng-bind="a"></div>')($rootScope);
2526
$rootScope.a = 'misko';
@@ -33,26 +34,19 @@ describe('ng-bind-*', function() {
3334
expect(element.text()).toEqual('');
3435
}));
3536

36-
it('should set html', inject(function($rootScope, $compile) {
37-
element = $compile('<div ng-bind-html="html"></div>')($rootScope);
38-
$rootScope.html = '<div unknown>hello</div>';
39-
$rootScope.$digest();
40-
expect(lowercase(element.html())).toEqual('<div>hello</div>');
41-
}));
42-
43-
it('should set unsafe html', inject(function($rootScope, $compile) {
44-
element = $compile('<div ng-bind-html-unsafe="html"></div>')($rootScope);
45-
$rootScope.html = '<div onclick="">hello</div>';
46-
$rootScope.$digest();
47-
expect(lowercase(element.html())).toEqual('<div onclick="">hello</div>');
48-
}));
4937

5038
it('should suppress rendering of falsy values', inject(function($rootScope, $compile) {
51-
element = $compile('<div>{{ null }}{{ undefined }}{{ "" }}-{{ 0 }}{{ false }}</div>')($rootScope);
39+
element = $compile('<div><span ng-bind="null"></span>' +
40+
'<span ng-bind="undefined"></span>' +
41+
'<span ng-bind="\'\'"></span>-' +
42+
'<span ng-bind="0"></span>' +
43+
'<span ng-bind="false"></span>' +
44+
'</div>')($rootScope);
5245
$rootScope.$digest();
5346
expect(element.text()).toEqual('-0false');
5447
}));
5548

49+
5650
it('should render object as JSON ignore $$', inject(function($rootScope, $compile) {
5751
element = $compile('<div>{{ {key:"value", $$key:"hide"} }}</div>')($rootScope);
5852
$rootScope.$digest();
@@ -71,10 +65,33 @@ describe('ng-bind-*', function() {
7165
expect(element.text()).toEqual('Hello Misko!');
7266
}));
7367

68+
7469
it('should render object as JSON ignore $$', inject(function($rootScope, $compile) {
7570
element = $compile('<pre>{{ {key:"value", $$key:"hide"} }}</pre>')($rootScope);
7671
$rootScope.$digest();
7772
expect(fromJson(element.text())).toEqual({key:'value'});
7873
}));
7974
});
75+
76+
77+
describe('ng-bind-html', function() {
78+
79+
it('should set html', inject(function($rootScope, $compile) {
80+
element = $compile('<div ng-bind-html="html"></div>')($rootScope);
81+
$rootScope.html = '<div unknown>hello</div>';
82+
$rootScope.$digest();
83+
expect(lowercase(element.html())).toEqual('<div>hello</div>');
84+
}));
85+
});
86+
87+
88+
describe('ng-bind-html-unsafe', function() {
89+
90+
it('should set unsafe html', inject(function($rootScope, $compile) {
91+
element = $compile('<div ng-bind-html-unsafe="html"></div>')($rootScope);
92+
$rootScope.html = '<div onclick="">hello</div>';
93+
$rootScope.$digest();
94+
expect(lowercase(element.html())).toEqual('<div onclick="">hello</div>');
95+
}));
96+
});
8097
});

0 commit comments

Comments
 (0)