mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
test(ngBindSpec): correct tests + split them up
This commit is contained in:
parent
82d90a4096
commit
dc7b764d4d
1 changed files with 31 additions and 14 deletions
|
|
@ -20,6 +20,7 @@ describe('ng-bind-*', function() {
|
|||
expect(element.text()).toEqual('misko');
|
||||
}));
|
||||
|
||||
|
||||
it('should set text to blank if undefined', inject(function($rootScope, $compile) {
|
||||
element = $compile('<div ng-bind="a"></div>')($rootScope);
|
||||
$rootScope.a = 'misko';
|
||||
|
|
@ -33,26 +34,19 @@ describe('ng-bind-*', function() {
|
|||
expect(element.text()).toEqual('');
|
||||
}));
|
||||
|
||||
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(lowercase(element.html())).toEqual('<div>hello</div>');
|
||||
}));
|
||||
|
||||
it('should set unsafe html', inject(function($rootScope, $compile) {
|
||||
element = $compile('<div ng-bind-html-unsafe="html"></div>')($rootScope);
|
||||
$rootScope.html = '<div onclick="">hello</div>';
|
||||
$rootScope.$digest();
|
||||
expect(lowercase(element.html())).toEqual('<div onclick="">hello</div>');
|
||||
}));
|
||||
|
||||
it('should suppress rendering of falsy values', inject(function($rootScope, $compile) {
|
||||
element = $compile('<div>{{ null }}{{ undefined }}{{ "" }}-{{ 0 }}{{ false }}</div>')($rootScope);
|
||||
element = $compile('<div><span ng-bind="null"></span>' +
|
||||
'<span ng-bind="undefined"></span>' +
|
||||
'<span ng-bind="\'\'"></span>-' +
|
||||
'<span ng-bind="0"></span>' +
|
||||
'<span ng-bind="false"></span>' +
|
||||
'</div>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
expect(element.text()).toEqual('-0false');
|
||||
}));
|
||||
|
||||
|
||||
it('should render object as JSON ignore $$', inject(function($rootScope, $compile) {
|
||||
element = $compile('<div>{{ {key:"value", $$key:"hide"} }}</div>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
|
|
@ -71,10 +65,33 @@ describe('ng-bind-*', function() {
|
|||
expect(element.text()).toEqual('Hello Misko!');
|
||||
}));
|
||||
|
||||
|
||||
it('should render object as JSON ignore $$', inject(function($rootScope, $compile) {
|
||||
element = $compile('<pre>{{ {key:"value", $$key:"hide"} }}</pre>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
expect(fromJson(element.text())).toEqual({key:'value'});
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
describe('ng-bind-html', function() {
|
||||
|
||||
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(lowercase(element.html())).toEqual('<div>hello</div>');
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
describe('ng-bind-html-unsafe', function() {
|
||||
|
||||
it('should set unsafe html', inject(function($rootScope, $compile) {
|
||||
element = $compile('<div ng-bind-html-unsafe="html"></div>')($rootScope);
|
||||
$rootScope.html = '<div onclick="">hello</div>';
|
||||
$rootScope.$digest();
|
||||
expect(lowercase(element.html())).toEqual('<div onclick="">hello</div>');
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue