@@ -20,6 +20,7 @@ describe('ng-bind-*', function() {
20
20
expect ( element . text ( ) ) . toEqual ( 'misko' ) ;
21
21
} ) ) ;
22
22
23
+
23
24
it ( 'should set text to blank if undefined' , inject ( function ( $rootScope , $compile ) {
24
25
element = $compile ( '<div ng-bind="a"></div>' ) ( $rootScope ) ;
25
26
$rootScope . a = 'misko' ;
@@ -33,26 +34,19 @@ describe('ng-bind-*', function() {
33
34
expect ( element . text ( ) ) . toEqual ( '' ) ;
34
35
} ) ) ;
35
36
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
- } ) ) ;
49
37
50
38
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 ) ;
52
45
$rootScope . $digest ( ) ;
53
46
expect ( element . text ( ) ) . toEqual ( '-0false' ) ;
54
47
} ) ) ;
55
48
49
+
56
50
it ( 'should render object as JSON ignore $$' , inject ( function ( $rootScope , $compile ) {
57
51
element = $compile ( '<div>{{ {key:"value", $$key:"hide"} }}</div>' ) ( $rootScope ) ;
58
52
$rootScope . $digest ( ) ;
@@ -71,10 +65,33 @@ describe('ng-bind-*', function() {
71
65
expect ( element . text ( ) ) . toEqual ( 'Hello Misko!' ) ;
72
66
} ) ) ;
73
67
68
+
74
69
it ( 'should render object as JSON ignore $$' , inject ( function ( $rootScope , $compile ) {
75
70
element = $compile ( '<pre>{{ {key:"value", $$key:"hide"} }}</pre>' ) ( $rootScope ) ;
76
71
$rootScope . $digest ( ) ;
77
72
expect ( fromJson ( element . text ( ) ) ) . toEqual ( { key :'value' } ) ;
78
73
} ) ) ;
79
74
} ) ;
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
+ } ) ;
80
97
} ) ;
0 commit comments