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

Commit 9f5ac04

Browse files
test(ngOptions): should place non-grouped items in the list where they appear
Closes #10531
1 parent 408f89d commit 9f5ac04

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/ng/directive/ngOptionsSpec.js

+30
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,36 @@ describe('ngOptions', function() {
944944
});
945945

946946

947+
it('should place non-grouped items in the list where they appear', function() {
948+
createSelect({
949+
'ng-model': 'selected',
950+
'ng-options': 'item.name group by item.group for item in values'
951+
});
952+
953+
scope.$apply(function() {
954+
scope.values = [{name: 'A'},
955+
{name: 'B', group: 'first'},
956+
{name: 'C', group: 'second'},
957+
{name: 'D'},
958+
{name: 'E', group: 'first'},
959+
{name: 'F'},
960+
{name: 'G'},
961+
{name: 'H', group: 'second'}];
962+
scope.selected = scope.values[0];
963+
});
964+
965+
var children = element.children();
966+
expect(children.length).toEqual(6);
967+
968+
expect(nodeName_(children[0])).toEqual('option');
969+
expect(nodeName_(children[1])).toEqual('optgroup');
970+
expect(nodeName_(children[2])).toEqual('optgroup');
971+
expect(nodeName_(children[3])).toEqual('option');
972+
expect(nodeName_(children[4])).toEqual('option');
973+
expect(nodeName_(children[5])).toEqual('option');
974+
});
975+
976+
947977
it('should bind to scope value and track/identify objects', function() {
948978
createSelect({
949979
'ng-model': 'selected',

0 commit comments

Comments
 (0)