@@ -509,7 +509,7 @@ describe('Multiselect.vue', () => {
509
509
describe ( '#watch:options' , ( ) => {
510
510
it ( 'sets loading to FALSE after options update' , ( done ) => {
511
511
const vm = new Vue ( {
512
- template : '<multiselect :selected="sel" :options="source" label="id" key="id" :searchable="true" :multiple="false" :on- search-change="onSearch"></multiselect>' ,
512
+ template : '<multiselect :selected="sel" :options="source" label="id" key="id" :searchable="true" :multiple="false" @ search-change="onSearch" :async="true "></multiselect>' ,
513
513
components : { Multiselect } ,
514
514
data : {
515
515
sel : { id : '2' } ,
@@ -534,7 +534,7 @@ describe('Multiselect.vue', () => {
534
534
describe ( '#watch:selected' , ( ) => {
535
535
it ( 'updates multiselect private value when parent selected changes to a different value than private value' , ( done ) => {
536
536
const vm = new Vue ( {
537
- template : '<multiselect :selected="sel" :options="source" label="id" key="id" :searchable="false" :on- change="addMore" :multiple="false"></multiselect>' ,
537
+ template : '<multiselect :selected="sel" :options="source" label="id" key="id" :searchable="false" @ change="addMore" :multiple="false"></multiselect>' ,
538
538
components : { Multiselect } ,
539
539
data : {
540
540
sel : { id : '2' } ,
@@ -557,7 +557,7 @@ describe('Multiselect.vue', () => {
557
557
describe ( '#watch:value' , ( ) => {
558
558
it ( 'calls onChange(option) callback when onChange prop is set' , ( done ) => {
559
559
const vm = new Vue ( {
560
- template : '<multiselect :selected="value" :options="source" label="id" key="id" :searchable="false" :on- change="afterSelect"></multiselect>' ,
560
+ template : '<multiselect :selected="value" :options="source" label="id" key="id" :searchable="false" @ change="afterSelect"></multiselect>' ,
561
561
components : { Multiselect } ,
562
562
data : {
563
563
value : null ,
@@ -579,7 +579,7 @@ describe('Multiselect.vue', () => {
579
579
} )
580
580
} )
581
581
582
- it ( 'changes the selected value when NO onChange prop is set ' , ( done ) => {
582
+ it ( 'not changing changes the selected value with no @change event listener ' , ( done ) => {
583
583
const vm = new Vue ( {
584
584
template : '<multiselect :selected.sync="value" :options="source" label="id" key="id" :searchable="false"></multiselect>' ,
585
585
components : { Multiselect } ,
@@ -591,9 +591,9 @@ describe('Multiselect.vue', () => {
591
591
} ) . $mount ( )
592
592
vm . $children [ 0 ] . select ( vm . $children [ 0 ] . options [ 0 ] )
593
593
Vue . nextTick ( function ( ) {
594
- expect ( vm . $children [ 0 ] . selected ) . to . deep . equal ( { id : '1' } )
594
+ expect ( vm . $children [ 0 ] . selected ) . to . deep . equal ( null )
595
595
expect ( vm . newValue ) . to . deep . equal ( null )
596
- expect ( vm . value ) . to . deep . equal ( { id : '1' } )
596
+ expect ( vm . value ) . to . deep . equal ( null )
597
597
done ( )
598
598
} )
599
599
} )
@@ -638,7 +638,7 @@ describe('Multiselect.vue', () => {
638
638
describe ( '#watch:search' , ( ) => {
639
639
it ( 'calls onSearchChange(searchQuery) callback when onSearchChange prop is set' , ( done ) => {
640
640
const vm = new Vue ( {
641
- template : '<multiselect :selected="value" :options="source" label="id" key="id" :searchable="true" :on- search-change="afterSearch" :clear-on-select="false"></multiselect>' ,
641
+ template : '<multiselect :selected="value" :options="source" label="id" key="id" :searchable="true" @ search-change="afterSearch" :clear-on-select="false"></multiselect>' ,
642
642
components : { Multiselect } ,
643
643
data : {
644
644
value : null ,
@@ -659,7 +659,7 @@ describe('Multiselect.vue', () => {
659
659
} )
660
660
it ( 'sets loading status to TRUE until the options change' , ( done ) => {
661
661
const vm = new Vue ( {
662
- template : '<multiselect :selected="value" :options="source" label="id" key="id" :searchable="true" :on- search-change="afterSearch"></multiselect>' ,
662
+ template : '<multiselect :selected="value" :options="source" label="id" key="id" :searchable="true" @ search-change="afterSearch" :async="true "></multiselect>' ,
663
663
components : { Multiselect } ,
664
664
data : {
665
665
value : null ,
@@ -1070,19 +1070,27 @@ describe('Multiselect.vue', () => {
1070
1070
describe ( '#onTag' , ( ) => {
1071
1071
it ( 'should should push to value and options with default settings and :taggable is TRUE' , ( ) => {
1072
1072
const vm = new Vue ( {
1073
- template : '<multiselect :selected="value" :searchable="true" :options="source" :multiple="true" :taggable="true"></multiselect>' ,
1073
+ template : '<multiselect :selected="value" :searchable="true" :options="source" :multiple="true" :taggable="true" @tag="addTag" ></multiselect>' ,
1074
1074
components : { Multiselect } ,
1075
- data : {
1076
- value : [ '1' ] ,
1077
- source : [ '1' , '2' , '3' ]
1075
+ data ( ) {
1076
+ return {
1077
+ value : [ '1' ] ,
1078
+ source : [ '1' , '2' , '3' ]
1079
+ }
1080
+ } ,
1081
+ methods : {
1082
+ addTag ( newTag ) {
1083
+ this . source . push ( newTag )
1084
+ this . value . push ( newTag )
1085
+ }
1078
1086
}
1079
1087
} ) . $mount ( )
1080
1088
vm . $children [ 0 ] . search = 'test'
1081
1089
vm . $children [ 0 ] . select ( vm . $children [ 0 ] . filteredOptions [ 0 ] )
1082
1090
expect ( vm . $children [ 0 ] . options . length ) . to . equal ( 4 )
1083
1091
expect ( vm . $children [ 0 ] . options ) . to . deep . equal ( [ '1' , '2' , '3' , 'test' ] )
1084
- expect ( vm . $children [ 0 ] . value . length ) . to . equal ( 2 )
1085
- expect ( vm . $children [ 0 ] . value ) . to . deep . equal ( [ '1' , 'test' ] )
1092
+ expect ( vm . $children [ 0 ] . selected . length ) . to . equal ( 2 )
1093
+ expect ( vm . $children [ 0 ] . selected ) . to . deep . equal ( [ '1' , 'test' ] )
1086
1094
} )
1087
1095
} )
1088
1096
0 commit comments