From 6e8bec6c831caceaa613c2c8d4eb8d8bffc60c8e Mon Sep 17 00:00:00 2001 From: Erin Altenhof-Long Date: Mon, 28 Jul 2014 09:29:42 -0700 Subject: [PATCH] test(select): add test against updating selected property on digest with no change event Commit dc149de9364c66b988f169f67cad39577ba43434 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. --- test/ng/directive/selectSpec.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/ng/directive/selectSpec.js b/test/ng/directive/selectSpec.js index 0a70517a..9ce01704 100644 --- a/test/ng/directive/selectSpec.js +++ b/test/ng/directive/selectSpec.js @@ -733,6 +733,27 @@ describe('select', function() { expect(sortedHtml(options[2])).toEqual(''); }); + 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() {