2013-01-29 19:34:14 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
2012-04-10 23:50:31 +00:00
|
|
|
describe('ngBindHtml', function() {
|
|
|
|
|
beforeEach(module('ngSanitize'));
|
|
|
|
|
|
|
|
|
|
it('should set html', inject(function($rootScope, $compile) {
|
2013-01-29 19:34:14 +00:00
|
|
|
var element = $compile('<div ng-bind-html="html"></div>')($rootScope);
|
2012-04-10 23:50:31 +00:00
|
|
|
$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) {
|
2013-01-29 19:34:14 +00:00
|
|
|
var element = $compile('<div ng-bind-html="html"></div>')($rootScope);
|
2012-04-10 23:50:31 +00:00
|
|
|
|
|
|
|
|
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('');
|
|
|
|
|
});
|
|
|
|
|
}));
|
|
|
|
|
});
|