@@ -2,6 +2,7 @@ import {enableAutoUnmount, mount} from '@vue/test-utils'
2
2
import { afterEach , beforeEach , describe , expect , it } from 'vitest'
3
3
import BOffcanvas from './BOffcanvas.vue'
4
4
import BCloseButton from '../BButton/BCloseButton.vue'
5
+ import BButton from '../BButton/BButton.vue'
5
6
import BOverlay from '../BOverlay/BOverlay.vue'
6
7
describe . skip ( 'offcanvas' , ( ) => {
7
8
enableAutoUnmount ( afterEach )
@@ -155,27 +156,103 @@ describe.skip('offcanvas', () => {
155
156
expect ( $closebutton . props ( 'type' ) ) . toBe ( 'button' )
156
157
} )
157
158
159
+ it ( 'first child div child BCloseButton has static class text-reset' , ( ) => {
160
+ const wrapper = mount ( BOffcanvas )
161
+ const [ , $div ] = wrapper . findAll ( 'div' )
162
+ const $closebutton = $div . getComponent ( BCloseButton )
163
+ expect ( $closebutton . classes ( ) ) . toContain ( 'text-reset' )
164
+ } )
165
+
158
166
it ( 'first child div child BCloseButton has prop ariaLabel to be default close' , ( ) => {
159
167
const wrapper = mount ( BOffcanvas )
160
168
const [ , $div ] = wrapper . findAll ( 'div' )
161
169
const $closebutton = $div . getComponent ( BCloseButton )
162
170
expect ( $closebutton . props ( 'ariaLabel' ) ) . toBe ( 'Close' )
163
171
} )
164
172
165
- it ( 'first child div child BCloseButton has prop ariaLabel to be prop dismissLabel ' , ( ) => {
173
+ it ( 'first child div child BCloseButton has prop ariaLabel to be prop headerCloseLabel ' , ( ) => {
166
174
const wrapper = mount ( BOffcanvas , {
167
- props : { dismissLabel : 'foobar' } ,
175
+ props : { headerCloseLabel : 'foobar' } ,
168
176
} )
169
177
const [ , $div ] = wrapper . findAll ( 'div' )
170
178
const $closebutton = $div . getComponent ( BCloseButton )
171
179
expect ( $closebutton . props ( 'ariaLabel' ) ) . toBe ( 'foobar' )
172
180
} )
173
181
174
- it ( 'first child div child BCloseButton has static class text-reset' , ( ) => {
175
- const wrapper = mount ( BOffcanvas )
182
+ it ( 'first child div child BCloseButton has class when prop headerCloseClass' , ( ) => {
183
+ const wrapper = mount ( BOffcanvas , {
184
+ props : { headerCloseClass : 'foobar' } ,
185
+ } )
176
186
const [ , $div ] = wrapper . findAll ( 'div' )
177
187
const $closebutton = $div . getComponent ( BCloseButton )
178
- expect ( $closebutton . classes ( ) ) . toContain ( 'text-reset' )
188
+ expect ( $closebutton . classes ( ) ) . toContain ( 'foobar' )
189
+ } )
190
+
191
+ it ( 'first child div child BCloseButton has class when prop headerCloseWhite' , ( ) => {
192
+ const wrapper = mount ( BOffcanvas , {
193
+ props : { headerCloseWhite : true } ,
194
+ } )
195
+ const [ , $div ] = wrapper . findAll ( 'div' )
196
+ const $closebutton = $div . getComponent ( BCloseButton )
197
+ expect ( $closebutton . classes ( ) ) . toContain ( 'btn-close-white' )
198
+ } )
199
+
200
+ it ( 'first child div child BCloseButton has not variant class when headerCloseVariant' , ( ) => {
201
+ const wrapper = mount ( BOffcanvas , {
202
+ props : { headerCloseVariant : 'warning' } ,
203
+ } )
204
+ const [ , $div ] = wrapper . findAll ( 'div' )
205
+ const $closebutton = $div . getComponent ( BCloseButton )
206
+ expect ( $closebutton . classes ( ) ) . not . toContain ( 'btn-warning' )
207
+ } )
208
+
209
+ it ( 'first child div child BButton has prop ariaLabel to be default close' , ( ) => {
210
+ const wrapper = mount ( BOffcanvas , {
211
+ slots : { 'header-close' : 'foobar' } ,
212
+ } )
213
+ const [ , $div ] = wrapper . findAll ( 'div' )
214
+ const $bbutton = $div . getComponent ( BButton )
215
+ expect ( $bbutton . props ( 'ariaLabel' ) ) . toBe ( 'Close' )
216
+ } )
217
+
218
+ it ( 'first child div child BButton has prop ariaLabel to be prop headerCloseLabel' , ( ) => {
219
+ const wrapper = mount ( BOffcanvas , {
220
+ props : { headerCloseLabel : 'foobar' } ,
221
+ slots : { 'header-close' : 'foobar' } ,
222
+ } )
223
+ const [ , $div ] = wrapper . findAll ( 'div' )
224
+ const $bbutton = $div . getComponent ( BButton )
225
+ expect ( $bbutton . props ( 'ariaLabel' ) ) . toBe ( 'foobar' )
226
+ } )
227
+
228
+ it ( 'first child div child BButton has class when prop headerCloseClass' , ( ) => {
229
+ const wrapper = mount ( BOffcanvas , {
230
+ props : { headerCloseClass : 'foobar' } ,
231
+ slots : { 'header-close' : 'foobar' } ,
232
+ } )
233
+ const [ , $div ] = wrapper . findAll ( 'div' )
234
+ const $bbutton = $div . getComponent ( BButton )
235
+ expect ( $bbutton . classes ( ) ) . toContain ( 'foobar' )
236
+ } )
237
+
238
+ it ( 'first child div child BButton has class when prop headerCloseWhite' , ( ) => {
239
+ const wrapper = mount ( BOffcanvas , {
240
+ props : { headerCloseWhite : true } ,
241
+ slots : { 'header-close' : 'foobar' } ,
242
+ } )
243
+ const [ , $div ] = wrapper . findAll ( 'div' )
244
+ const $bbutton = $div . getComponent ( BButton )
245
+ expect ( $bbutton . classes ( ) ) . not . toContain ( 'btn-close-white' )
246
+ } )
247
+
248
+ it ( 'first child div child BButton has variant class when headerCloseVariant' , ( ) => {
249
+ const wrapper = mount ( BOffcanvas , {
250
+ props : { headerCloseVariant : 'warning' } ,
251
+ slots : { 'header-close' : 'foobar' } ,
252
+ } )
253
+ const [ , $div ] = wrapper . findAll ( 'div' )
254
+ const $bbutton = $div . getComponent ( BButton )
255
+ expect ( $bbutton . classes ( ) ) . toContain ( 'btn-warning' )
179
256
} )
180
257
181
258
it ( 'second child div has static class offcanvas-body' , ( ) => {
0 commit comments