'use strict'; describe("markups", function(){ var compile, element, scope; beforeEach(function() { scope = null; element = null; compile = function(html) { element = jqLite(html); scope = angular.compile(element)(); }; }); afterEach(function(){ dealoc(element); }); it('should translate {{}} in text', function(){ compile('
');
expect(element.attr('ng:bind-attr')).toEqual('{"src":"http://server/{{path}}.png"}');
scope.$set('path', 'a/b');
scope.$eval();
expect(element.attr('src')).toEqual("http://server/a/b.png");
});
describe('OPTION value', function(){
beforeEach(function(){
this.addMatchers({
toHaveValue: function(expected){
this.message = function(){
return 'Expected "' + this.actual.html() + '" to have value="' + expected + '".';
};
var value;
htmlParser(this.actual.html(), {
start:function(tag, attrs){
value = attrs.value;
},
end:noop,
chars:noop
});
return trim(value) == trim(expected);
}
});
});
it('should populate value attribute on OPTION', function(){
compile('');
expect(element).toHaveValue('abc');
});
it('should ignore value if already exists', function(){
compile('');
expect(element).toHaveValue('abc');
});
it('should set value even if newlines present', function(){
compile('');
expect(element).toHaveValue('\nabc\n');
});
it('should set value even if self closing HTML', function(){
// IE removes the \n from option, which makes this test pointless
if (msie) return;
compile('');
expect(element).toHaveValue('\n');
});
});
it('should bind href', function() {
compile('');
expect(sortedHtml(element)).toEqual('');
});
it('should bind disabled', function() {
compile('');
scope.isDisabled = false;
scope.$eval();
expect(element.attr('disabled')).toBeFalsy();
scope.isDisabled = true;
scope.$eval();
expect(element.attr('disabled')).toBeTruthy();
});
it('should bind checked', function() {
compile('');
scope.isChecked = false;
scope.$eval();
expect(element.attr('checked')).toBeFalsy();
scope.isChecked=true;
scope.$eval();
expect(element.attr('checked')).toBeTruthy();
});
it('should bind selected', function() {
compile('');
scope.isSelected=false;
scope.$eval();
expect(element.children()[1].selected).toBeFalsy();
scope.isSelected=true;
scope.$eval();
expect(element.children()[1].selected).toBeTruthy();
});
it('should bind readonly', function() {
compile('');
scope.isReadonly=false;
scope.$eval();
expect(element.attr('readOnly')).toBeFalsy();
scope.isReadonly=true;
scope.$eval();
expect(element.attr('readOnly')).toBeTruthy();
});
it('should bind multiple', function() {
compile('');
scope.isMultiple=false;
scope.$eval();
expect(element.attr('multiple')).toBeFalsy();
scope.isMultiple='multiple';
scope.$eval();
expect(element.attr('multiple')).toBeTruthy();
});
it('should bind src', function() {
compile('