aboutsummaryrefslogtreecommitdiffstats
path: root/test/ngSanitize/directive/ngBindHtmlSpec.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/ngSanitize/directive/ngBindHtmlSpec.js')
-rw-r--r--test/ngSanitize/directive/ngBindHtmlSpec.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/ngSanitize/directive/ngBindHtmlSpec.js b/test/ngSanitize/directive/ngBindHtmlSpec.js
new file mode 100644
index 00000000..be23e5a5
--- /dev/null
+++ b/test/ngSanitize/directive/ngBindHtmlSpec.js
@@ -0,0 +1,25 @@
+describe('ngBindHtml', function() {
+ beforeEach(module('ngSanitize'));
+
+ it('should set html', inject(function($rootScope, $compile) {
+ element = $compile('<div ng-bind-html="html"></div>')($rootScope);
+ $rootScope.html = '<div unknown>hello</div>';
+ $rootScope.$digest();
+ expect(angular.lowercase(element.html())).toEqual('<div>hello</div>');
+ }));
+
+
+ it('should reset html when value is null or undefined', inject(function($compile, $rootScope) {
+ element = $compile('<div ng-bind-html="html"></div>')($rootScope);
+
+ angular.forEach([null, undefined, ''], function(val) {
+ $rootScope.html = 'some val';
+ $rootScope.$digest();
+ expect(angular.lowercase(element.html())).toEqual('some val');
+
+ $rootScope.html = val;
+ $rootScope.$digest();
+ expect(angular.lowercase(element.html())).toEqual('');
+ });
+ }));
+});