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

Commit 95fcaf5

Browse files
committed
fixup! fix expectations
1 parent 5346af5 commit 95fcaf5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/ng/directive/selectSpec.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -2317,31 +2317,33 @@ describe('select', function() {
23172317
});
23182318

23192319
it('should keep the ngModel value when the selected option is recreated by ngRepeat', function() {
2320-
2321-
scope.options = ['A', 'B', 'C'];
2320+
scope.options = [{ name: 'A'}, { name: 'B'}, { name: 'C'}];
23222321
scope.obj = {
23232322
value: 'B'
23242323
};
23252324

23262325
compile(
23272326
'<select ng-model="obj.value">' +
2328-
'<option ng-repeat="option in options" value="{{option}}">{{option}}</option>' +
2327+
'<option ng-repeat="option in options" value="{{option.name}}">{{option.name}}</option>' +
23292328
'</select>'
23302329
);
23312330

23322331
var optionElements = element.find('option');
23332332
expect(optionElements.length).toEqual(3);
23342333
expect(optionElements[0].value).toBe('A');
23352334
expect(optionElements[1]).toBeMarkedAsSelected();
2335+
expect(scope.obj.value).toBe('B');
23362336

23372337
scope.$apply(function() {
2338-
scope.options = ['B', 'C', 'D'];
2338+
// Only when new objects are used, ngRepeat re-creates the element from scratch
2339+
scope.options = [{ name: 'B'}, { name: 'C'}, { name: 'D'}];
23392340
});
23402341

23412342
optionElements = element.find('option');
23422343
expect(optionElements.length).toEqual(3);
23432344
expect(optionElements[0].value).toBe('B');
23442345
expect(optionElements[0]).toBeMarkedAsSelected();
2346+
expect(scope.obj.value).toBe('B');
23452347
});
23462348

23472349
});

0 commit comments

Comments
 (0)