Skip to content

Commit 38ea53e

Browse files
committed
fix(ng:options): select correct element when '?'-option was previously selected
Closes angular#599
1 parent fec16a4 commit 38ea53e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/widget/selectSpec.js

+16
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,22 @@ describe('select', function() {
428428
expect(select.val()).toEqual('0');
429429
expect(select.find('option').length).toEqual(1);
430430
});
431+
432+
it('should select correct input if previously bound to something not in the list', function() {
433+
createSingleSelect();
434+
scope.values = [{name:'A'},{name:'B'}];
435+
scope.selected = {};
436+
scope.$digest();
437+
expect(select.find('option').length).toEqual(3);
438+
expect(select.val()).toEqual('?');
439+
expect(jqLite(select.find('option')[0]).val()).toEqual('?');
440+
441+
select.find('option').eq(1).prop('selected', true);
442+
browserTrigger(select, 'change');
443+
expect(select.val()).toEqual('0');
444+
expect(select.find('option').eq(0).prop('selected')).toBeTruthy();
445+
expect(select.find('option').length).toEqual(2);
446+
});
431447
});
432448

433449
describe('on change', function() {

0 commit comments

Comments
 (0)