mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-04-08 09:01:02 +00:00
26 lines
868 B
JavaScript
26 lines
868 B
JavaScript
|
|
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('');
|
||
|
|
});
|
||
|
|
}));
|
||
|
|
});
|