@@ -295,6 +295,15 @@ describe('Select.vue', () => {
295
295
expect ( vm . $refs . select . filteredOptions ) . toEqual ( [ 'bar' , 'baz' ] )
296
296
} )
297
297
298
+ it ( 'should not filter the array of strings if filterOptions is false' , ( ) => {
299
+ const vm = new Vue ( {
300
+ template : `<div><v-select ref="select" :filter-options="false" :options="['foo','bar','baz']" v-model="value"></v-select></div>` ,
301
+ data : { value : 'foo' }
302
+ } ) . $mount ( )
303
+ vm . $refs . select . search = 'ba'
304
+ expect ( vm . $refs . select . filteredOptions ) . toEqual ( [ 'foo' , 'bar' , 'baz' ] )
305
+ } )
306
+
298
307
it ( 'should filter without case-sensitivity' , ( ) => {
299
308
const vm = new Vue ( {
300
309
template : `<div><v-select ref="select" :options="['Foo','Bar','Baz']" v-model="value"></v-select></div>` ,
@@ -872,6 +881,21 @@ describe('Select.vue', () => {
872
881
expect ( vm . $children [ 0 ] . mutableOptions ) . toEqual ( [ 'one' , 'two' , 'three' ] )
873
882
} )
874
883
884
+ it ( 'should add a freshly created option/tag to the options list when pushTags is true and filterOptions is false' , ( ) => {
885
+ const vm = new Vue ( {
886
+ template : '<div><v-select :options="options" push-tags :value="value" :filter-options="false" :multiple="true" :taggable="true"></v-select></div>' ,
887
+ components : { vSelect} ,
888
+ data : {
889
+ value : [ 'one' ] ,
890
+ options : [ 'one' , 'two' ]
891
+ }
892
+ } ) . $mount ( )
893
+
894
+ searchSubmit ( vm , 'three' )
895
+ expect ( vm . $children [ 0 ] . mutableOptions ) . toEqual ( [ 'one' , 'two' , 'three' ] )
896
+ expect ( vm . $children [ 0 ] . filteredOptions ) . toEqual ( [ 'one' , 'two' , 'three' ] )
897
+ } )
898
+
875
899
it ( 'wont add a freshly created option/tag to the options list when pushTags is false' , ( ) => {
876
900
const vm = new Vue ( {
877
901
template : '<div><v-select :options="options" :value="value" :multiple="true" :taggable="true"></v-select></div>' ,
@@ -886,6 +910,21 @@ describe('Select.vue', () => {
886
910
expect ( vm . $children [ 0 ] . mutableOptions ) . toEqual ( [ 'one' , 'two' ] )
887
911
} )
888
912
913
+ it ( 'wont add a freshly created option/tag to the options list when pushTags is false and filterOptions is false' , ( ) => {
914
+ const vm = new Vue ( {
915
+ template : '<div><v-select :options="options" :value="value" :multiple="true" :filter-options="false" :taggable="true"></v-select></div>' ,
916
+ components : { vSelect} ,
917
+ data : {
918
+ value : [ 'one' ] ,
919
+ options : [ 'one' , 'two' ]
920
+ }
921
+ } ) . $mount ( )
922
+
923
+ searchSubmit ( vm , 'three' )
924
+ expect ( vm . $children [ 0 ] . mutableOptions ) . toEqual ( [ 'one' , 'two' ] )
925
+ expect ( vm . $children [ 0 ] . filteredOptions ) . toEqual ( [ 'one' , 'two' ] )
926
+ } )
927
+
889
928
it ( 'should select an existing option if the search string matches a string from options' , ( done ) => {
890
929
let two = 'two'
891
930
const vm = new Vue ( {
@@ -927,6 +966,28 @@ describe('Select.vue', () => {
927
966
} )
928
967
} )
929
968
969
+ it ( 'should select an existing option if the search string matches an objects label from options when filter-options is false' , ( done ) => {
970
+ let two = { label : 'two' }
971
+ const vm = new Vue ( {
972
+ template : '<div><v-select :options="options" taggable :filter-options="false"></v-select></div>' ,
973
+ data : {
974
+ options : [ { label : 'one' } , two ]
975
+ }
976
+ } ) . $mount ( )
977
+
978
+ vm . $children [ 0 ] . search = 'two'
979
+
980
+ Vue . nextTick ( ( ) => {
981
+ searchSubmit ( vm )
982
+ // This needs to be wrapped in nextTick() twice so that filteredOptions can
983
+ // calculate after setting the search text, and move the typeAheadPointer index to 0.
984
+ Vue . nextTick ( ( ) => {
985
+ expect ( vm . $children [ 0 ] . mutableValue . label ) . toBe ( two . label )
986
+ done ( )
987
+ } )
988
+ } )
989
+ } )
990
+
930
991
it ( 'should not reset the selected value when the options property changes' , ( done ) => {
931
992
const vm = new Vue ( {
932
993
template : '<div><v-select :options="options" :value="value" :multiple="true" taggable></v-select></div>' ,
@@ -943,6 +1004,22 @@ describe('Select.vue', () => {
943
1004
} )
944
1005
} )
945
1006
1007
+ it ( 'should not reset the selected value when the options property changes when filterOptions is false' , ( done ) => {
1008
+ const vm = new Vue ( {
1009
+ template : '<div><v-select :options="options" :value="value" :multiple="true" :filter-options="false" taggable></v-select></div>' ,
1010
+ components : { vSelect} ,
1011
+ data : {
1012
+ value : [ { label : 'one' } ] ,
1013
+ options : [ { label : 'one' } ]
1014
+ }
1015
+ } ) . $mount ( )
1016
+ vm . $children [ 0 ] . mutableOptions = [ { label : 'two' } ]
1017
+ Vue . nextTick ( ( ) => {
1018
+ expect ( vm . $children [ 0 ] . mutableValue ) . toEqual ( [ { label : 'one' } ] )
1019
+ done ( )
1020
+ } )
1021
+ } )
1022
+
946
1023
it ( 'should not allow duplicate tags when using string options' , ( done ) => {
947
1024
const vm = new Vue ( {
948
1025
template : `<div><v-select ref="select" taggable multiple></v-select></div>` ,
0 commit comments