@@ -2,17 +2,19 @@ import { mount, Wrapper } from '@vue/test-utils'
2
2
3
3
import SelectMulti from '../src/SelectMulti.vue'
4
4
5
+ const options = [
6
+ { label : 'Item One' , value : 'one' } ,
7
+ { label : 'Item Two' , value : 'two' } ,
8
+ { label : 'Item Three' , value : 'three' }
9
+ ]
10
+
5
11
describe ( 'SelectMulti' , ( ) => {
6
12
let wrapper : Wrapper < Vue >
7
13
8
14
describe ( 'given simple options' , ( ) => {
9
15
beforeEach ( ( ) => {
10
16
// TODO: Share sample data between spec files & Storybook stories
11
- const options = [
12
- { label : 'Item One' , value : 'one' } ,
13
- { label : 'Item Two' , value : 'two' } ,
14
- { label : 'Item Three' , value : 'three' }
15
- ]
17
+
16
18
17
19
wrapper = mount ( {
18
20
data ( ) {
@@ -65,11 +67,6 @@ describe('SelectMulti', () => {
65
67
} )
66
68
describe ( 'label functionality' , ( ) => {
67
69
it ( 'adds the aria-labelledby attribute to the listbox' , ( ) => {
68
- const options = [
69
- { label : 'Item One' , value : 'one' } ,
70
- { label : 'Item Two' , value : 'two' } ,
71
- { label : 'Item Three' , value : 'three' }
72
- ]
73
70
wrapper = mount ( {
74
71
data ( ) {
75
72
return { selectedOptions : [ ] , options } } ,
@@ -81,5 +78,41 @@ describe('SelectMulti', () => {
81
78
expect ( Object . keys ( input . attributes ( ) ) ) . toContain ( 'aria-labelledby' )
82
79
} )
83
80
} )
81
+
82
+ describe ( 'iconIsClickable works' , ( ) => {
83
+ it ( 'when iconIsClickable false its not clickable and wrapper is a div' , ( ) => {
84
+
85
+ wrapper = mount ( {
86
+ data ( ) {
87
+ return { selectedOptions : [ ] , options } } ,
88
+ template : '<div><SelectMulti :options="options" v-model="selectedOptions" label="Sample SelectMulti" /></div>' ,
89
+ components : { SelectMulti }
90
+ } )
91
+
92
+ const selectMulti = wrapper . findComponent ( SelectMulti )
93
+
94
+ const inputIconBlock = selectMulti . find ( '.combo-input-icon-block' )
95
+
96
+ expect ( inputIconBlock . element . tagName === 'DIV' ) . toBeTruthy ( )
97
+ expect ( inputIconBlock . classes ( 'not-clickable' ) ) . toBe ( true )
98
+ } )
99
+
100
+ it ( 'when iconIsClickable true its clickable and wrapper is a button' , ( ) => {
101
+
102
+ wrapper = mount ( {
103
+ data ( ) {
104
+ return { selectedOptions : [ ] , options } } ,
105
+ template : '<div><SelectMulti :options="options" v-model="selectedOptions" :iconIsClickable="true" label="Sample SelectMulti" /></div>' ,
106
+ components : { SelectMulti }
107
+ } )
108
+
109
+ const selectMulti = wrapper . findComponent ( SelectMulti )
110
+
111
+ const inputIconBlock = selectMulti . find ( '.combo-input-icon-block' )
112
+
113
+ expect ( inputIconBlock . element . tagName === 'BUTTON' ) . toBeTruthy ( )
114
+ expect ( inputIconBlock . classes ( 'not-clickable' ) ) . toBe ( false )
115
+ } )
116
+ } )
84
117
} )
85
118
} )
0 commit comments