Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 48568b4

Browse files
Erin Altenhof-Longpetebacondarwin
Erin Altenhof-Long
authored andcommitted
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 f92f52e commit 48568b4

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
@@ -1148,6 +1148,31 @@ describe('select', function() {
11481148
browserTrigger(element, 'change');
11491149
expect(scope.selected).toEqual(null);
11501150
});
1151+
1152+
1153+
// Regression https://github.com/angular/angular.js/issues/7855
1154+
it('should update the model with ng-change', function() {
1155+
createSelect({
1156+
'ng-change':'change()',
1157+
'ng-model':'selected',
1158+
'ng-options':'value for value in values'
1159+
});
1160+
1161+
scope.$apply(function() {
1162+
scope.values = ['A', 'B'];
1163+
scope.selected = 'A';
1164+
});
1165+
1166+
scope.change = function() {
1167+
scope.selected = 'A';
1168+
};
1169+
1170+
element.find('option')[1].selected = true;
1171+
1172+
browserTrigger(element, 'change');
1173+
expect(element.find('option')[0].selected).toBeTruthy();
1174+
expect(scope.selected).toEqual('A');
1175+
});
11511176
});
11521177

11531178
describe('disabled blank', function() {
@@ -1237,6 +1262,7 @@ describe('select', function() {
12371262
expect(scope.selected).toEqual([scope.values[0]]);
12381263
});
12391264

1265+
12401266
it('should select from object', function() {
12411267
createSelect({
12421268
'ng-model':'selected',

0 commit comments

Comments
 (0)