1
- import { TransitionStub , shallowMount } from '@vue/test-utils'
1
+ import { enableAutoDestroy , TransitionStub , shallowMount } from '@vue/test-utils'
2
2
3
3
import DropDown from 'components/DropDown'
4
4
import Icon from 'components/Icon'
@@ -26,9 +26,6 @@ describe('DropDown Vue component', () => {
26
26
</div>
27
27
` ,
28
28
} ,
29
- stubs : {
30
- transition : TransitionStub ,
31
- } ,
32
29
} )
33
30
} )
34
31
@@ -128,7 +125,7 @@ describe('DropDown Vue component', () => {
128
125
expect ( wrapper . classes ( 'drop-down' ) ) . toBe ( true )
129
126
} )
130
127
131
- it ( 'contains a link that toggles the drop down open and closed' , ( done ) => {
128
+ it ( 'contains a link that toggles the drop down open and closed' , async ( ) => {
132
129
const toggleCollapseSpy = spyOn ( wrapper . vm , 'toggleCollapse' )
133
130
. and . callThrough ( )
134
131
const toggleLink = wrapper . find ( 'a' )
@@ -141,42 +138,41 @@ describe('DropDown Vue component', () => {
141
138
expect ( toggleCollapseSpy ) . not . toHaveBeenCalled ( )
142
139
143
140
toggleLink . element . click ( )
141
+ await wrapper . vm . $nextTick ( )
144
142
145
- wrapper . vm . $nextTick ( ( ) => {
146
- expect ( dropDownContent . isVisible ( ) ) . toBe ( true )
147
- expect ( toggleCollapseSpy ) . toHaveBeenCalledTimes ( 1 )
143
+ expect ( dropDownContent . isVisible ( ) ) . toBe ( true )
144
+ expect ( toggleCollapseSpy ) . toHaveBeenCalledTimes ( 1 )
148
145
149
- toggleLink . element . click ( )
146
+ toggleLink . element . click ( )
147
+ await wrapper . vm . $nextTick ( )
150
148
151
- wrapper . vm . $nextTick ( ( ) => {
152
- expect ( dropDownContent . isVisible ( ) ) . toBe ( false )
153
- expect ( toggleCollapseSpy ) . toHaveBeenCalledTimes ( 2 )
154
- done ( )
155
- } )
156
- } )
149
+ expect ( dropDownContent . isVisible ( ) ) . toBe ( false )
150
+ expect ( toggleCollapseSpy ) . toHaveBeenCalledTimes ( 2 )
157
151
} )
158
152
159
- it ( 'contains a caret icon which changes based on expanded/collpased state' , ( ) => {
153
+ it ( 'contains a caret icon which changes based on expanded/collpased state' , async ( ) => {
160
154
const caretIcon = wrapper . find ( Icon )
161
155
162
156
expect ( caretIcon . exists ( ) ) . toBe ( true )
163
157
164
158
wrapper . setData ( { expanded : true } )
159
+ await wrapper . vm . $nextTick ( )
165
160
166
161
expect ( caretIcon . props ( 'title' ) ) . toEqual ( 'Collapse' )
167
162
expect ( caretIcon . props ( 'name' ) ) . toEqual ( 'caret-up' )
168
163
expect ( caretIcon . props ( 'color' ) ) . toEqual ( '000000' )
169
164
expect ( caretIcon . props ( 'size' ) ) . toEqual ( 12 )
170
165
171
166
wrapper . setData ( { expanded : false } )
167
+ await wrapper . vm . $nextTick ( )
172
168
173
169
expect ( caretIcon . props ( 'title' ) ) . toEqual ( 'Expand' )
174
170
expect ( caretIcon . props ( 'name' ) ) . toEqual ( 'caret-down' )
175
171
expect ( caretIcon . props ( 'color' ) ) . toEqual ( '000000' )
176
172
expect ( caretIcon . props ( 'size' ) ) . toEqual ( 12 )
177
173
} )
178
174
179
- it ( 'uses the v-click-outside directive to collapse the drop down' , ( done ) => {
175
+ it ( 'uses the v-click-outside directive to collapse the drop down' , async ( ) => {
180
176
const dropDownContent = wrapper . find ( '.drop-down__content' )
181
177
182
178
const divNode = document . createElement ( 'div' )
@@ -185,19 +181,17 @@ describe('DropDown Vue component', () => {
185
181
document . body . appendChild ( divNode )
186
182
187
183
wrapper . setData ( { expanded : true } )
184
+ await wrapper . vm . $nextTick ( )
188
185
189
186
expect ( dropDownContent . exists ( ) ) . toBe ( true )
190
187
expect ( dropDownContent . isVisible ( ) ) . toBe ( true )
191
188
192
189
divNode . click ( )
190
+ await wrapper . vm . $nextTick ( )
193
191
194
- wrapper . vm . $nextTick ( ( ) => {
195
- expect ( dropDownContent . isVisible ( ) ) . toBe ( false )
196
-
197
- divNode . remove ( )
192
+ expect ( dropDownContent . isVisible ( ) ) . toBe ( false )
198
193
199
- done ( )
200
- } )
194
+ divNode . remove ( )
201
195
} )
202
196
} )
203
- } )
197
+ } )
0 commit comments