Skip to content

Commit 143c6d9

Browse files
committed
Added test for multiple and tagging/
1 parent 83c0418 commit 143c6d9

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

test/select.spec.js

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1838,6 +1838,7 @@ describe('ui-select tests', function() {
18381838
if (attrs.taggingLabel !== undefined) { attrsHtml += ' tagging-label="' + attrs.taggingLabel + '"'; }
18391839
if (attrs.inputId !== undefined) { attrsHtml += ' input-id="' + attrs.inputId + '"'; }
18401840
if (attrs.groupBy !== undefined) { choicesAttrsHtml += ' group-by="' + attrs.groupBy + '"'; }
1841+
if (attrs.uiDisableChoice !== undefined) { choicesAttrsHtml += ' ui-disable-choice="' + attrs.uiDisableChoice + '"'; }
18411842
if (attrs.lockChoice !== undefined) { matchesAttrsHtml += ' ui-lock-choice="' + attrs.lockChoice + '"'; }
18421843
if (attrs.removeSelected !== undefined) { attrsHtml += ' remove-selected="' + attrs.removeSelected + '"'; }
18431844
if (attrs.resetSearchInput !== undefined) { attrsHtml += ' reset-search-input="' + attrs.resetSearchInput + '"'; }
@@ -2831,6 +2832,36 @@ describe('ui-select tests', function() {
28312832
$timeout.flush();
28322833
expect(scope.$model.name).toEqual('Natasha');
28332834
expect(el.scope().$select.selected.length).toEqual(2);
2835+
2836+
it('should ignore disable items key up with tagging on false', function() {
2837+
var el = createUiSelectMultiple({uiDisableChoice:"person.age == 12", tagging:false});
2838+
openDropdown(el);
2839+
var searchInput = el.find('.ui-select-search');
2840+
expect(el.scope().$select.activeIndex).toBe(-1);
2841+
triggerKeydown(searchInput, Key.Down);
2842+
triggerKeydown(searchInput, Key.Enter);
2843+
expect(el.scope().$select.activeIndex).toBe(2);
2844+
});
2845+
2846+
it('should ignore disable items key up with tagging on true', function() {
2847+
var el = createUiSelectMultiple({uiDisableChoice:"person.age == 12", tagging:true});
2848+
openDropdown(el);
2849+
var searchInput = el.find('.ui-select-search');
2850+
expect(el.scope().$select.activeIndex).toBe(-1);
2851+
triggerKeydown(searchInput, Key.Down);
2852+
expect(el.scope().$select.activeIndex).toBe(2);
2853+
triggerKeydown(searchInput, Key.Up);
2854+
expect(el.scope().$select.activeIndex).toBe(-1);
2855+
});
2856+
2857+
it('should ignore disable items key down', function() {
2858+
var el = createUiSelectMultiple({uiDisableChoice:"person.age == 12"});
2859+
openDropdown(el);
2860+
var searchInput = el.find('.ui-select-search');
2861+
expect(el.scope().$select.activeIndex).toBe(0);
2862+
triggerKeydown(searchInput, Key.Down);
2863+
triggerKeydown(searchInput, Key.Enter);
2864+
expect(el.scope().$select.activeIndex).toBe(2);
28342865
});
28352866

28362867
describe('resetSearchInput option multiple', function () {
@@ -2842,6 +2873,7 @@ describe('ui-select tests', function() {
28422873
expect(createUiSelectMultiple({ resetSearchInput: false }).scope().$select.resetSearchInput).toBe(false);
28432874
});
28442875
});
2876+
28452877

28462878
describe('Reset the search value', function () {
28472879
it('should clear the search input when resetSearchInput is true', function () {
@@ -3189,6 +3221,37 @@ describe('ui-select tests', function() {
31893221
triggerKeydown(searchInput, Key.Up);
31903222
expect(el.scope().$select.activeIndex).toBe(0);
31913223
});
3192-
});
31933224

3225+
it('should ignore disable items key up with tagging on true', function() {
3226+
var el = createUiSelect({uiDisableChoice:"person.age == 12", tagging:true});
3227+
openDropdown(el);
3228+
var searchInput = el.find('.ui-select-search');
3229+
expect(el.scope().$select.activeIndex).toBe(-1);
3230+
triggerKeydown(searchInput, Key.Down);
3231+
expect(el.scope().$select.activeIndex).toBe(2);
3232+
triggerKeydown(searchInput, Key.Up);
3233+
expect(el.scope().$select.activeIndex).toBe(-1);
3234+
});
3235+
3236+
it('should ignore disable items key up with tagging on false', function() {
3237+
var el = createUiSelect({uiDisableChoice:"person.age == 12", tagging:false});
3238+
openDropdown(el);
3239+
var searchInput = el.find('.ui-select-search');
3240+
expect(el.scope().$select.activeIndex).toBe(-1);
3241+
triggerKeydown(searchInput, Key.Down);
3242+
triggerKeydown(searchInput, Key.Enter);
3243+
expect(el.scope().$select.activeIndex).toBe(2);
3244+
});
3245+
3246+
it('should ignore disable items key up with tagging on true with custom tag', function() {
3247+
var el = createUiSelect({uiDisableChoice:"person.age == 12", tagging:true, taggingLabel:'custom tag'});
3248+
openDropdown(el);
3249+
var searchInput = el.find('.ui-select-search');
3250+
expect(el.scope().$select.activeIndex).toBe(-1);
3251+
triggerKeydown(searchInput, Key.Down);
3252+
triggerKeydown(searchInput, Key.Enter);
3253+
expect(el.scope().$select.activeIndex).toBe(2);
3254+
});
3255+
});
3256+
});
31943257
});

0 commit comments

Comments
 (0)