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

Commit ede182e

Browse files
test(ngOptions): should not insert a blank option if one of the options maps to null
Closes #7605
1 parent 091fbf2 commit ede182e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/ng/directive/ngOptionsSpec.js

+21
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,27 @@ describe('ngOptions', function() {
11511151
});
11521152

11531153

1154+
it('should not insert a blank option if one of the options maps to null', function() {
1155+
createSelect({
1156+
'ng-model': 'myColor',
1157+
'ng-options': 'color.shade as color.name for color in colors',
1158+
});
1159+
1160+
scope.$apply(function() {
1161+
scope.colors = [
1162+
{name:'nothing', shade:null},
1163+
{name:'red', shade:'dark'}
1164+
];
1165+
scope.myColor = null;
1166+
});
1167+
1168+
expect(element.find('option').length).toEqual(2);
1169+
expect(element.find('option').eq(0)).toEqualOption(null);
1170+
expect(element.val()).not.toEqualUnknownValue(null);
1171+
expect(element.find('option').eq(0)).not.toEqualUnknownOption(null);
1172+
});
1173+
1174+
11541175
it('should insert a unknown option if bound to something not in the list', function() {
11551176
createSingleSelect();
11561177

0 commit comments

Comments
 (0)