test(select): add test of updating the model because of ng-change
A regression #7855 was introduced by https://github.com/angular/angular.js/commit/dc149de9364c66b988f169f67cad39577ba43434 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
This commit is contained in:
committed by
Peter Bacon Darwin
parent
b770c353bc
commit
d018ac2a9a
@@ -1134,6 +1134,31 @@ describe('select', function() {
|
||||
browserTrigger(element, 'change');
|
||||
expect(scope.selected).toEqual(null);
|
||||
});
|
||||
|
||||
|
||||
// Regression https://github.com/angular/angular.js/issues/7855
|
||||
it('should update the model with ng-change', function() {
|
||||
createSelect({
|
||||
'ng-change':'change()',
|
||||
'ng-model':'selected',
|
||||
'ng-options':'value for value in values'
|
||||
});
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.values = ['A', 'B'];
|
||||
scope.selected = 'A';
|
||||
});
|
||||
|
||||
scope.change = function() {
|
||||
scope.selected = 'A';
|
||||
};
|
||||
|
||||
element.find('option')[1].selected = true;
|
||||
|
||||
browserTrigger(element, 'change');
|
||||
expect(element.find('option')[0].selected).toBeTruthy();
|
||||
expect(scope.selected).toEqual('A');
|
||||
});
|
||||
});
|
||||
|
||||
describe('disabled blank', function() {
|
||||
@@ -1223,6 +1248,7 @@ describe('select', function() {
|
||||
expect(scope.selected).toEqual([scope.values[0]]);
|
||||
});
|
||||
|
||||
|
||||
it('should select from object', function() {
|
||||
createSelect({
|
||||
'ng-model':'selected',
|
||||
|
||||
Reference in New Issue
Block a user