@@ -249,6 +249,36 @@ describe('Select.vue', () => {
249
249
expect ( vm . $children [ 0 ] . isOptionSelected ( 'foo' ) ) . toEqual ( true )
250
250
} ) ,
251
251
252
+ it ( 'applies the "empty" class to the search input when no value is selected' , ( ) => {
253
+ const vm = new Vue ( {
254
+ template : '<div><v-select :options="options" multiple v-model="value"></v-select></div>' ,
255
+ components : { vSelect} ,
256
+ data : {
257
+ value : null ,
258
+ options : [ { label : 'one' } ]
259
+ }
260
+ } ) . $mount ( )
261
+
262
+ expect ( vm . $children [ 0 ] . inputClasses . empty ) . toEqual ( true )
263
+ expect ( vm . $children [ 0 ] . inputClasses . shrunk ) . toEqual ( false )
264
+ expect ( vm . $children [ 0 ] . inputClasses . hidden ) . toEqual ( false )
265
+ } ) ,
266
+
267
+ it ( 'applies the "shrunk" class to the search input when one or more value is selected' , ( ) => {
268
+ const vm = new Vue ( {
269
+ template : '<div><v-select :options="options" multiple v-model="value"></v-select></div>' ,
270
+ components : { vSelect} ,
271
+ data : {
272
+ value : [ { label : 'one' } ] ,
273
+ options : [ { label : 'one' } ]
274
+ }
275
+ } ) . $mount ( )
276
+
277
+ expect ( vm . $children [ 0 ] . inputClasses . shrunk ) . toEqual ( true )
278
+ expect ( vm . $children [ 0 ] . inputClasses . empty ) . toEqual ( false )
279
+ expect ( vm . $children [ 0 ] . inputClasses . hidden ) . toEqual ( false )
280
+ } ) ,
281
+
252
282
describe ( 'change Event' , ( ) => {
253
283
it ( 'will trigger the input event when the selection changes' , ( done ) => {
254
284
const vm = new Vue ( {
@@ -1318,7 +1348,56 @@ describe('Select.vue', () => {
1318
1348
expect ( vm . $refs . select . search ) . toEqual ( '' )
1319
1349
done ( )
1320
1350
} )
1321
- } )
1351
+ } )
1352
+
1353
+ it ( 'should apply the "empty" class to the search input when it does not have a selected value' , ( ) => {
1354
+ const vm = new Vue ( {
1355
+ template : '<div><v-select ref="select" :options="options" :value="value"></v-select></div>' ,
1356
+ data : {
1357
+ value : '' ,
1358
+ options : [ 'one' , 'two' , 'three' ]
1359
+ }
1360
+ } ) . $mount ( )
1361
+ expect ( vm . $children [ 0 ] . inputClasses . empty ) . toEqual ( true )
1362
+ expect ( vm . $children [ 0 ] . inputClasses . shrunk ) . toEqual ( false )
1363
+ expect ( vm . $children [ 0 ] . inputClasses . hidden ) . toEqual ( false )
1364
+ } )
1365
+
1366
+ it ( 'should apply the "hidden" class to the search input when a value is present' , ( ) => {
1367
+ const vm = new Vue ( {
1368
+ template : '<div><v-select ref="select" :options="options" :value="value"></v-select></div>' ,
1369
+ data : {
1370
+ value : 'one' ,
1371
+ options : [ 'one' , 'two' , 'three' ]
1372
+ }
1373
+ } ) . $mount ( )
1374
+
1375
+ expect ( vm . $children [ 0 ] . inputClasses . hidden ) . toEqual ( true )
1376
+ expect ( vm . $children [ 0 ] . inputClasses . empty ) . toEqual ( false )
1377
+ expect ( vm . $children [ 0 ] . inputClasses . shrunk ) . toEqual ( false )
1378
+ } )
1379
+
1380
+
1381
+ it ( 'should not apply the "hidden" class to the search input when a value is present, and the dropdown is open' , ( ) => {
1382
+ const vm = new Vue ( {
1383
+ template : '<div><v-select ref="select" :options="options" :value="value"></v-select></div>' ,
1384
+ data : {
1385
+ value : 'one' ,
1386
+ options : [ 'one' , 'two' , 'three' ] ,
1387
+ open : true
1388
+ }
1389
+ } ) . $mount ( )
1390
+ vm . $children [ 0 ] . toggleDropdown ( { target : vm . $children [ 0 ] . $refs . search } )
1391
+ Vue . nextTick ( ( ) => {
1392
+ Vue . nextTick ( ( ) => {
1393
+ expect ( vm . $children [ 0 ] . open ) . toEqual ( true )
1394
+ expect ( vm . $children [ 0 ] . inputClasses . hidden ) . toEqual ( false )
1395
+ expect ( vm . $children [ 0 ] . inputClasses . empty ) . toEqual ( false )
1396
+ expect ( vm . $children [ 0 ] . inputClasses . shrunk ) . toEqual ( false )
1397
+ done ( )
1398
+ } )
1399
+ } )
1400
+ } )
1322
1401
1323
1402
it ( 'should not reset the search input on focus lost when clearSearchOnSelect is false' , ( done ) => {
1324
1403
const vm = new Vue ( {
0 commit comments