@@ -156,24 +156,6 @@ describe('alert', () => {
156
156
expect ( $bclosebutton . exists ( ) ) . toBe ( false )
157
157
} )
158
158
159
- it ( 'nested div does not have BCloseButton when prop dismissible but also prop closeContent' , ( ) => {
160
- const wrapper = mount ( BAlert , {
161
- props : { modelValue : true , dismissible : true , closeContent : 'foobar' } ,
162
- } )
163
- const $div = wrapper . get ( 'div' )
164
- const $bclosebutton = $div . findComponent ( BCloseButton )
165
- expect ( $bclosebutton . exists ( ) ) . toBe ( false )
166
- } )
167
-
168
- it ( 'nested div has BButton when prop dismissible but also prop closeContent' , ( ) => {
169
- const wrapper = mount ( BAlert , {
170
- props : { modelValue : true , dismissible : true , closeContent : 'foobar' } ,
171
- } )
172
- const $div = wrapper . get ( 'div' )
173
- const $bbutton = $div . findComponent ( BButton )
174
- expect ( $bbutton . exists ( ) ) . toBe ( true )
175
- } )
176
-
177
159
it ( 'nested div has BButton when prop dismissible but also slot close' , ( ) => {
178
160
const wrapper = mount ( BAlert , {
179
161
props : { modelValue : true , dismissible : true } ,
@@ -193,60 +175,52 @@ describe('alert', () => {
193
175
expect ( $bbutton . exists ( ) ) . toBe ( false )
194
176
} )
195
177
196
- it ( 'nested div BButton has static attr type to be button' , ( ) => {
197
- const wrapper = mount ( BAlert , {
198
- props : { modelValue : true , dismissible : true , closeContent : 'foobar' } ,
199
- } )
200
- const $div = wrapper . get ( 'div' )
201
- const $bbutton = $div . getComponent ( BButton )
202
- expect ( $bbutton . attributes ( 'type' ) ) . toBe ( 'button' )
203
- } )
204
-
205
- it ( 'nested div BButton renders prop closeContent' , ( ) => {
178
+ it ( 'nested div BButton renders slot close' , ( ) => {
206
179
const wrapper = mount ( BAlert , {
207
- props : { modelValue : true , dismissible : true , closeContent : 'foobar' } ,
180
+ props : { modelValue : true , dismissible : true } ,
181
+ slots : { close : 'foobar' } ,
208
182
} )
209
183
const $div = wrapper . get ( 'div' )
210
184
const $bbutton = $div . getComponent ( BButton )
211
185
expect ( $bbutton . text ( ) ) . toBe ( 'foobar' )
212
186
} )
213
187
214
- it ( 'nested div BButton renders slot close ' , ( ) => {
188
+ it ( 'nested div BCloseButton has aria-label to be Close by default ' , ( ) => {
215
189
const wrapper = mount ( BAlert , {
216
190
props : { modelValue : true , dismissible : true } ,
217
- slots : { close : 'foobar' } ,
218
191
} )
219
192
const $div = wrapper . get ( 'div' )
220
- const $bbutton = $div . getComponent ( BButton )
221
- expect ( $bbutton . text ( ) ) . toBe ( 'foobar ' )
193
+ const $bclosebutton = $div . getComponent ( BCloseButton )
194
+ expect ( $bclosebutton . attributes ( 'aria-label' ) ) . toBe ( 'Close ' )
222
195
} )
223
196
224
- it ( 'nested div BButton renders slot over props ' , ( ) => {
197
+ it ( 'nested div BButton has aria-label to be Close by default ' , ( ) => {
225
198
const wrapper = mount ( BAlert , {
226
- props : { modelValue : true , dismissible : true , closeContent : 'props' } ,
227
- slots : { close : 'slots ' } ,
199
+ props : { modelValue : true , dismissible : true } ,
200
+ slots : { close : 'foobar ' } ,
228
201
} )
229
202
const $div = wrapper . get ( 'div' )
230
203
const $bbutton = $div . getComponent ( BButton )
231
- expect ( $bbutton . text ( ) ) . toBe ( 'slots ' )
204
+ expect ( $bbutton . attributes ( 'aria-label' ) ) . toBe ( 'Close ' )
232
205
} )
233
206
234
- it ( 'nested div BCloseButton has aria-label to be Close by default ' , ( ) => {
207
+ it ( 'nested div BCloseButton has aria-label to be prop closeLabel ' , ( ) => {
235
208
const wrapper = mount ( BAlert , {
236
- props : { modelValue : true , dismissible : true } ,
209
+ props : { modelValue : true , dismissible : true , closeLabel : 'foobar' } ,
237
210
} )
238
211
const $div = wrapper . get ( 'div' )
239
212
const $bclosebutton = $div . getComponent ( BCloseButton )
240
- expect ( $bclosebutton . attributes ( 'aria-label' ) ) . toBe ( 'Close ' )
213
+ expect ( $bclosebutton . attributes ( 'aria-label' ) ) . toBe ( 'foobar ' )
241
214
} )
242
215
243
- it ( 'nested div BCloseButton has aria-label to be prop dismissLabel ' , ( ) => {
216
+ it ( 'nested div BButton has aria-label to be prop closeLabel ' , ( ) => {
244
217
const wrapper = mount ( BAlert , {
245
- props : { modelValue : true , dismissible : true , dismissLabel : 'foobar' } ,
218
+ props : { modelValue : true , dismissible : true , closeLabel : 'foobar' } ,
219
+ slots : { close : 'foobar' } ,
246
220
} )
247
221
const $div = wrapper . get ( 'div' )
248
- const $bclosebutton = $div . getComponent ( BCloseButton )
249
- expect ( $bclosebutton . attributes ( 'aria-label' ) ) . toBe ( 'foobar' )
222
+ const $bbutton = $div . getComponent ( BButton )
223
+ expect ( $bbutton . attributes ( 'aria-label' ) ) . toBe ( 'foobar' )
250
224
} )
251
225
252
226
// BCloseButton variant
@@ -292,19 +266,56 @@ describe('alert', () => {
292
266
expect ( emitted [ 0 ] [ 0 ] ) . toBe ( 0 )
293
267
} )
294
268
295
- it ( 'nested div BCloseButton clicked emits closed ' , async ( ) => {
269
+ it ( 'nested div BCloseButton clicked emits close ' , async ( ) => {
296
270
const wrapper = mount ( BAlert , {
297
271
props : { modelValue : 5 , dismissible : true } ,
298
272
} )
299
273
const $div = wrapper . get ( 'div' )
300
274
const $bclosebutton = $div . getComponent ( BCloseButton )
301
275
await $bclosebutton . trigger ( 'click' )
302
- expect ( wrapper . emitted ( ) ) . toHaveProperty ( 'closed' )
276
+ expect ( wrapper . emitted ( ) ) . toHaveProperty ( 'close' )
277
+ } )
278
+
279
+ it ( 'nested div BCloseButton has class when prop closeClass' , ( ) => {
280
+ const wrapper = mount ( BAlert , {
281
+ props : { modelValue : true , dismissible : true , closeClass : 'foobar' } ,
282
+ } )
283
+ const $div = wrapper . get ( 'div' )
284
+ const $bclosebutton = $div . getComponent ( BCloseButton )
285
+ expect ( $bclosebutton . classes ( ) ) . toContain ( 'foobar' )
286
+ } )
287
+
288
+ it ( 'nested div BCloseButton has class when prop closeWhite' , ( ) => {
289
+ const wrapper = mount ( BAlert , {
290
+ props : { modelValue : true , dismissible : true , closeWhite : true } ,
291
+ } )
292
+ const $div = wrapper . get ( 'div' )
293
+ const $bclosebutton = $div . getComponent ( BCloseButton )
294
+ expect ( $bclosebutton . classes ( ) ) . toContain ( 'btn-close-white' )
295
+ } )
296
+
297
+ it ( 'nested div BCloseButton has no class when no slot close' , ( ) => {
298
+ const wrapper = mount ( BAlert , {
299
+ props : { modelValue : true , dismissible : true } ,
300
+ } )
301
+ const $div = wrapper . get ( 'div' )
302
+ const $bclosebutton = $div . getComponent ( BCloseButton )
303
+ expect ( $bclosebutton . classes ( ) ) . not . toContain ( 'btn-close-custom' )
304
+ } )
305
+
306
+ it ( 'nested div BCloseButton has no variant class when closeVariant' , ( ) => {
307
+ const wrapper = mount ( BAlert , {
308
+ props : { modelValue : true , dismissible : true , closeVariant : 'warning' } ,
309
+ } )
310
+ const $div = wrapper . get ( 'div' )
311
+ const $bclosebutton = $div . getComponent ( BCloseButton )
312
+ expect ( $bclosebutton . classes ( ) ) . not . toContain ( 'btn-warning' )
303
313
} )
304
314
// BButton variant
305
315
it ( 'nested div BButton emits update:modelValue when clicked when modelValue boolean' , async ( ) => {
306
316
const wrapper = mount ( BAlert , {
307
- props : { modelValue : true , dismissible : true , closeContent : 'foobar' } ,
317
+ props : { modelValue : true , dismissible : true } ,
318
+ slots : { close : 'foobar' } ,
308
319
} )
309
320
const $div = wrapper . get ( 'div' )
310
321
const $bbutton = $div . getComponent ( BButton )
@@ -314,7 +325,8 @@ describe('alert', () => {
314
325
315
326
it ( 'nested div BButton clicked update:modelValue emits arg false when modelValue boolean' , async ( ) => {
316
327
const wrapper = mount ( BAlert , {
317
- props : { modelValue : true , dismissible : true , closeContent : 'foobar' } ,
328
+ props : { modelValue : true , dismissible : true } ,
329
+ slots : { close : 'foobar' } ,
318
330
} )
319
331
const $div = wrapper . get ( 'div' )
320
332
const $bbutton = $div . getComponent ( BButton )
@@ -325,7 +337,8 @@ describe('alert', () => {
325
337
326
338
it ( 'nested div BButton emits update:modelValue when clicked when modelValue number > 0' , async ( ) => {
327
339
const wrapper = mount ( BAlert , {
328
- props : { modelValue : 5 , dismissible : true , closeContent : 'foobar' } ,
340
+ props : { modelValue : 5 , dismissible : true } ,
341
+ slots : { close : 'foobar' } ,
329
342
} )
330
343
const $div = wrapper . get ( 'div' )
331
344
const $bbutton = $div . getComponent ( BButton )
@@ -335,7 +348,8 @@ describe('alert', () => {
335
348
336
349
it ( 'nested div BButton clicked update:modelValue emits arg 0 when modelValue number > 0' , async ( ) => {
337
350
const wrapper = mount ( BAlert , {
338
- props : { modelValue : 5 , dismissible : true , closeContent : 'foobar' } ,
351
+ props : { modelValue : 5 , dismissible : true } ,
352
+ slots : { close : 'foobar' } ,
339
353
} )
340
354
const $div = wrapper . get ( 'div' )
341
355
const $bbutton = $div . getComponent ( BButton )
@@ -344,14 +358,55 @@ describe('alert', () => {
344
358
expect ( emitted [ 0 ] [ 0 ] ) . toBe ( 0 )
345
359
} )
346
360
347
- it ( 'nested div BButton clicked emits closed ' , async ( ) => {
361
+ it ( 'nested div BButton clicked emits close ' , async ( ) => {
348
362
const wrapper = mount ( BAlert , {
349
- props : { modelValue : 5 , dismissible : true , closeContent : 'foobar' } ,
363
+ props : { modelValue : 5 , dismissible : true } ,
364
+ slots : { close : 'foobar' } ,
350
365
} )
351
366
const $div = wrapper . get ( 'div' )
352
367
const $bbutton = $div . getComponent ( BButton )
353
368
await $bbutton . trigger ( 'click' )
354
- expect ( wrapper . emitted ( ) ) . toHaveProperty ( 'closed' )
369
+ expect ( wrapper . emitted ( ) ) . toHaveProperty ( 'close' )
370
+ } )
371
+
372
+ it ( 'nested div BButton has class when prop closeClass' , ( ) => {
373
+ const wrapper = mount ( BAlert , {
374
+ props : { modelValue : true , dismissible : true , closeClass : 'foobar' } ,
375
+ slots : { close : 'foobar' } ,
376
+ } )
377
+ const $div = wrapper . get ( 'div' )
378
+ const $bbutton = $div . getComponent ( BButton )
379
+ expect ( $bbutton . classes ( ) ) . toContain ( 'foobar' )
380
+ } )
381
+
382
+ it ( 'nested div BButton has no class when prop closeWhite' , ( ) => {
383
+ const wrapper = mount ( BAlert , {
384
+ props : { modelValue : true , dismissible : true , closeWhite : true } ,
385
+ slots : { close : 'foobar' } ,
386
+ } )
387
+ const $div = wrapper . get ( 'div' )
388
+ const $bbutton = $div . getComponent ( BButton )
389
+ expect ( $bbutton . classes ( ) ) . not . toContain ( 'btn-close-white' )
390
+ } )
391
+
392
+ it ( 'nested div BButton has class when slot close' , ( ) => {
393
+ const wrapper = mount ( BAlert , {
394
+ props : { modelValue : true , dismissible : true } ,
395
+ slots : { close : 'foobar' } ,
396
+ } )
397
+ const $div = wrapper . get ( 'div' )
398
+ const $bbutton = $div . getComponent ( BButton )
399
+ expect ( $bbutton . classes ( ) ) . toContain ( 'btn-close-custom' )
400
+ } )
401
+
402
+ it ( 'nested div BButton has variant class when closeVariant' , ( ) => {
403
+ const wrapper = mount ( BAlert , {
404
+ props : { modelValue : true , dismissible : true , closeVariant : 'warning' } ,
405
+ slots : { close : 'foobar' } ,
406
+ } )
407
+ const $div = wrapper . get ( 'div' )
408
+ const $bbutton = $div . getComponent ( BButton )
409
+ expect ( $bbutton . classes ( ) ) . toContain ( 'btn-warning' )
355
410
} )
356
411
357
412
// TODO try to test countdown items
0 commit comments