Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d018ac2

Browse files
Erin Altenhof-Longpetebacondarwin
Erin Altenhof-Long
authored andcommittedJul 30, 2014
test(select): add test of updating the model because of ng-change
A regression #7855 was introduced by 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 #7855
1 parent b770c35 commit d018ac2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
 

‎test/ng/directive/selectSpec.js

Lines changed: 26 additions & 0 deletions
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)
This repository has been archived.