Skip to content

Commit 314f854

Browse files
author
Erin Altenhof-Long
committed
test(select): add test of updating the model because of ng-change
A regression angular#7855 was introduced by angular@dc149de This test ensures that reverting that commit fixes this regression. In the regression, changes to a bound model in ng-change were not propagated back to the view.
1 parent b86f8b6 commit 314f854

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/ng/directive/selectSpec.js

+25
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,31 @@ describe('select', function() {
12231223
expect(scope.selected).toEqual([scope.values[0]]);
12241224
});
12251225

1226+
// Regression https://github.com/angular/angular.js/issues/7855
1227+
it('should update the model with ng-change', function() {
1228+
createSelect({
1229+
'ng-change':'change()',
1230+
'ng-model':'selected',
1231+
'ng-options':'value for value in values'
1232+
});
1233+
1234+
scope.$apply(function() {
1235+
scope.values = ['A', 'B'];
1236+
scope.selected = 'A';
1237+
});
1238+
1239+
scope.change = function() {
1240+
scope.selected = 'A';
1241+
};
1242+
1243+
element.find('option')[1].selected = true;
1244+
1245+
browserTrigger(element, 'change');
1246+
expect(element.find('option')[0].selected).toBeTruthy();
1247+
expect(scope.selected).toEqual('A');
1248+
});
1249+
1250+
12261251
it('should select from object', function() {
12271252
createSelect({
12281253
'ng-model':'selected',

0 commit comments

Comments
 (0)