Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 2782103

Browse files
committed
Add tests for search enabled option.
1 parent 4f1034b commit 2782103

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

test/select.spec.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,4 +552,66 @@ describe('ui-select tests', function() {
552552

553553
});
554554

555+
describe('search-enabled option', function() {
556+
557+
var el;
558+
559+
function setupSelectComponent(searchEnabled, theme) {
560+
el = compileTemplate(
561+
'<ui-select ng-model="selection.selected" theme="' + theme + '" search-enabled="' + searchEnabled + '"> \
562+
<ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
563+
<ui-select-choices repeat="person in people | filter: $select.search"> \
564+
<div ng-bind-html="person.name | highlight: $select.search"></div> \
565+
<div ng-bind-html="person.email | highlight: $select.search"></div> \
566+
</ui-select-choices> \
567+
</ui-select>'
568+
);
569+
}
570+
571+
describe('selectize theme', function() {
572+
573+
it('should show search input when true', function() {
574+
setupSelectComponent('true', 'selectize');
575+
expect($(el).find('.ui-select-search')).not.toHaveClass('ng-hide');
576+
});
577+
578+
it('should hide search input when false', function() {
579+
setupSelectComponent('false', 'selectize');
580+
expect($(el).find('.ui-select-search')).toHaveClass('ng-hide');
581+
});
582+
583+
});
584+
585+
describe('select2 theme', function() {
586+
587+
it('should show search input when true', function() {
588+
setupSelectComponent('true', 'select2');
589+
expect($(el).find('.select2-search')).not.toHaveClass('ng-hide');
590+
});
591+
592+
it('should hide search input when false', function() {
593+
setupSelectComponent('false', 'select2');
594+
expect($(el).find('.select2-search')).toHaveClass('ng-hide');
595+
});
596+
597+
});
598+
599+
describe('bootstrap theme', function() {
600+
601+
it('should show search input when true', function() {
602+
setupSelectComponent('true', 'bootstrap');
603+
clickMatch(el);
604+
expect($(el).find('.ui-select-search')).not.toHaveClass('ng-hide');
605+
});
606+
607+
it('should hide search input when false', function() {
608+
setupSelectComponent('false', 'bootstrap');
609+
clickMatch(el);
610+
expect($(el).find('.ui-select-search')).toHaveClass('ng-hide');
611+
});
612+
613+
});
614+
615+
});
616+
555617
});

0 commit comments

Comments
 (0)