test(select): add test cases for selects with blank disabled options

An earlier commit dc149de936 caused an error where the first option of
a select would be skipped over if it had a blank disabled value. These tests demonstrate that with
that commit in place, blank disabled options are skipped in a select. When the commit is reverted,
the correct behavior is seen that the blank disabled option is still selected in both selects
marked with required and those that have optional choices.

Relates to #7715
This commit is contained in:
Erin Altenhof-Long
2014-07-16 11:43:47 -07:00
committed by Peter Bacon Darwin
parent 812277c257
commit b770c353bc

View File

@@ -1136,6 +1136,46 @@ describe('select', function() {
});
});
describe('disabled blank', function() {
it('should select disabled blank by default', function() {
var html = '<select ng-model="someModel" ng-options="c for c in choices">' +
'<option value="" disabled>Choose One</option>' +
'</select>';
scope.$apply(function() {
scope.choices = ['A', 'B', 'C'];
});
compile(html);
var options = element.find('option');
var optionToSelect = options.eq(0);
expect(optionToSelect.text()).toBe('Choose One');
expect(optionToSelect.prop('selected')).toBe(true);
expect(element[0].value).toBe('');
dealoc(element);
});
it('should select disabled blank by default when select is required', function() {
var html = '<select ng-model="someModel" ng-options="c for c in choices" required>' +
'<option value="" disabled>Choose One</option>' +
'</select>';
scope.$apply(function() {
scope.choices = ['A', 'B', 'C'];
});
compile(html);
var options = element.find('option');
var optionToSelect = options.eq(0);
expect(optionToSelect.text()).toBe('Choose One');
expect(optionToSelect.prop('selected')).toBe(true);
expect(element[0].value).toBe('');
dealoc(element);
});
});
describe('select-many', function() {