test(select): add test against updating selected property on digest with no change event

Commit dc149de936 was reverted to fix regressions #7715 and #7855.
This commit introduced this test case and a corresponding fix for preventing the update of the
selected property of an option element on a digest with no change event. Although the previous fix
introduced regressions, the test covers a valid issue and should be included.
This commit is contained in:
Erin Altenhof-Long
2014-07-28 09:29:42 -07:00
committed by Peter Bacon Darwin
parent c306d251f4
commit 6e8bec6c83

View File

@@ -733,6 +733,27 @@ describe('select', function() {
expect(sortedHtml(options[2])).toEqual('<option value="1">3</option>');
});
it('should not update selected property of an option element on digest with no change event',
function() {
createSingleSelect();
scope.$apply(function() {
scope.values = [{name: 'A'}, {name: 'B'}, {name: 'C'}];
scope.selected = scope.values[0];
});
var options = element.find('option');
var optionToSelect = options.eq(1);
expect(optionToSelect.text()).toBe('B');
optionToSelect.prop('selected', true);
scope.$digest();
expect(optionToSelect.prop('selected')).toBe(true);
expect(scope.selected).toBe(scope.values[0]);
});
describe('binding', function() {
it('should bind to scope value', function() {