@@ -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>` ,
@@ -888,6 +897,21 @@ describe('Select.vue', () => {
888
897
expect ( vm . $children [ 0 ] . mutableOptions ) . toEqual ( [ 'one' , 'two' , 'three' ] )
889
898
} )
890
899
900
+ it ( 'should add a freshly created option/tag to the options list when pushTags is true and filterOptions is false' , ( ) => {
901
+ const vm = new Vue ( {
902
+ template : '<div><v-select :options="options" push-tags :value="value" :filter-options="false" :multiple="true" :taggable="true"></v-select></div>' ,
903
+ components : { vSelect} ,
904
+ data : {
905
+ value : [ 'one' ] ,
906
+ options : [ 'one' , 'two' ]
907
+ }
908
+ } ) . $mount ( )
909
+
910
+ searchSubmit ( vm , 'three' )
911
+ expect ( vm . $children [ 0 ] . mutableOptions ) . toEqual ( [ 'one' , 'two' , 'three' ] )
912
+ expect ( vm . $children [ 0 ] . filteredOptions ) . toEqual ( [ 'one' , 'two' , 'three' ] )
913
+ } )
914
+
891
915
it ( 'wont add a freshly created option/tag to the options list when pushTags is false' , ( ) => {
892
916
const vm = new Vue ( {
893
917
template : '<div><v-select :options="options" :value="value" :multiple="true" :taggable="true"></v-select></div>' ,
@@ -902,6 +926,21 @@ describe('Select.vue', () => {
902
926
expect ( vm . $children [ 0 ] . mutableOptions ) . toEqual ( [ 'one' , 'two' ] )
903
927
} )
904
928
929
+ it ( 'wont add a freshly created option/tag to the options list when pushTags is false and filterOptions is false' , ( ) => {
930
+ const vm = new Vue ( {
931
+ template : '<div><v-select :options="options" :value="value" :multiple="true" :filter-options="false" :taggable="true"></v-select></div>' ,
932
+ components : { vSelect} ,
933
+ data : {
934
+ value : [ 'one' ] ,
935
+ options : [ 'one' , 'two' ]
936
+ }
937
+ } ) . $mount ( )
938
+
939
+ searchSubmit ( vm , 'three' )
940
+ expect ( vm . $children [ 0 ] . mutableOptions ) . toEqual ( [ 'one' , 'two' ] )
941
+ expect ( vm . $children [ 0 ] . filteredOptions ) . toEqual ( [ 'one' , 'two' ] )
942
+ } )
943
+
905
944
it ( 'should select an existing option if the search string matches a string from options' , ( done ) => {
906
945
let two = 'two'
907
946
const vm = new Vue ( {
@@ -943,6 +982,28 @@ describe('Select.vue', () => {
943
982
} )
944
983
} )
945
984
985
+ it ( 'should select an existing option if the search string matches an objects label from options when filter-options is false' , ( done ) => {
986
+ let two = { label : 'two' }
987
+ const vm = new Vue ( {
988
+ template : '<div><v-select :options="options" taggable :filter-options="false"></v-select></div>' ,
989
+ data : {
990
+ options : [ { label : 'one' } , two ]
991
+ }
992
+ } ) . $mount ( )
993
+
994
+ vm . $children [ 0 ] . search = 'two'
995
+
996
+ Vue . nextTick ( ( ) => {
997
+ searchSubmit ( vm )
998
+ // This needs to be wrapped in nextTick() twice so that filteredOptions can
999
+ // calculate after setting the search text, and move the typeAheadPointer index to 0.
1000
+ Vue . nextTick ( ( ) => {
1001
+ expect ( vm . $children [ 0 ] . mutableValue . label ) . toBe ( two . label )
1002
+ done ( )
1003
+ } )
1004
+ } )
1005
+ } )
1006
+
946
1007
it ( 'should not reset the selected value when the options property changes' , ( done ) => {
947
1008
const vm = new Vue ( {
948
1009
template : '<div><v-select :options="options" :value="value" :multiple="true" taggable></v-select></div>' ,
@@ -959,6 +1020,22 @@ describe('Select.vue', () => {
959
1020
} )
960
1021
} )
961
1022
1023
+ it ( 'should not reset the selected value when the options property changes when filterOptions is false' , ( done ) => {
1024
+ const vm = new Vue ( {
1025
+ template : '<div><v-select :options="options" :value="value" :multiple="true" :filter-options="false" taggable></v-select></div>' ,
1026
+ components : { vSelect} ,
1027
+ data : {
1028
+ value : [ { label : 'one' } ] ,
1029
+ options : [ { label : 'one' } ]
1030
+ }
1031
+ } ) . $mount ( )
1032
+ vm . $children [ 0 ] . mutableOptions = [ { label : 'two' } ]
1033
+ Vue . nextTick ( ( ) => {
1034
+ expect ( vm . $children [ 0 ] . mutableValue ) . toEqual ( [ { label : 'one' } ] )
1035
+ done ( )
1036
+ } )
1037
+ } )
1038
+
962
1039
it ( 'should not allow duplicate tags when using string options' , ( done ) => {
963
1040
const vm = new Vue ( {
964
1041
template : `<div><v-select ref="select" taggable multiple></v-select></div>` ,
0 commit comments