Skip to content

Commit 39315ff

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. Test for angular#7855
1 parent 22b9261 commit 39315ff

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/ng/directive/selectSpec.js

+26
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,31 @@ describe('select', function() {
11341134
browserTrigger(element, 'change');
11351135
expect(scope.selected).toEqual(null);
11361136
});
1137+
1138+
1139+
// Regression https://github.com/angular/angular.js/issues/7855
1140+
it('should update the model with ng-change', function() {
1141+
createSelect({
1142+
'ng-change':'change()',
1143+
'ng-model':'selected',
1144+
'ng-options':'value for value in values'
1145+
});
1146+
1147+
scope.$apply(function() {
1148+
scope.values = ['A', 'B'];
1149+
scope.selected = 'A';
1150+
});
1151+
1152+
scope.change = function() {
1153+
scope.selected = 'A';
1154+
};
1155+
1156+
element.find('option')[1].selected = true;
1157+
1158+
browserTrigger(element, 'change');
1159+
expect(element.find('option')[0].selected).toBeTruthy();
1160+
expect(scope.selected).toEqual('A');
1161+
});
11371162
});
11381163

11391164
describe('disabled blank', function() {
@@ -1223,6 +1248,7 @@ describe('select', function() {
12231248
expect(scope.selected).toEqual([scope.values[0]]);
12241249
});
12251250

1251+
12261252
it('should select from object', function() {
12271253
createSelect({
12281254
'ng-model':'selected',

0 commit comments

Comments
 (0)