@@ -247,6 +247,37 @@ def test_accordion_and_accordiongroup(self):
247
247
assert html .count ('name="password1"' ) == 1
248
248
assert html .count ('name="password2"' ) == 1
249
249
250
+ def test_accordion_css_class_is_applied (self ):
251
+ classes = "one two three"
252
+ test_form = SampleForm ()
253
+ test_form .helper = FormHelper ()
254
+ test_form .helper .form_tag = False
255
+ test_form .helper .layout = Layout (
256
+ Accordion (
257
+ AccordionGroup ("one" , "first_name" ),
258
+ css_class = classes ,
259
+ css_id = "super-accordion" ,
260
+ )
261
+ )
262
+ html = render_crispy_form (test_form )
263
+
264
+ assert html .count ('<div class="%s" id="super-accordion"' % classes ) == 1
265
+
266
+ def test_accordion_group_css_class_is_applied (self ):
267
+ classes = "one two three"
268
+ test_form = SampleForm ()
269
+ test_form .helper = FormHelper ()
270
+ test_form .helper .form_tag = False
271
+ test_form .helper .layout = Layout (
272
+ Accordion (
273
+ AccordionGroup ("one" , "first_name" ),
274
+ AccordionGroup ("two" , "password1" , "password2" , css_class = classes ),
275
+ )
276
+ )
277
+ html = render_crispy_form (test_form )
278
+
279
+ assert html .count ('<div class="card mb-2 %s"' % classes ) == 1
280
+
250
281
def test_accordion_active_false_not_rendered (self ):
251
282
test_form = SampleForm ()
252
283
test_form .helper = FormHelper ()
@@ -302,30 +333,15 @@ def test_tab_and_tab_holder(self):
302
333
"one" ,
303
334
"first_name" ,
304
335
css_id = "custom-name" ,
305
- css_class = "first-tab-class active " ,
336
+ css_class = "first-tab-class" ,
306
337
),
307
338
Tab ("two" , "password1" , "password2" ),
339
+ css_class = "test-tab-holder-class" ,
308
340
)
309
341
)
310
- html = render_crispy_form (test_form )
311
-
312
- assert (
313
- html .count (
314
- '<ul class="nav nav-tabs"> <li class="nav-item">'
315
- '<a class="nav-link active" href="#custom-name" data-toggle="tab">'
316
- "One</a></li>"
317
- )
318
- == 1
342
+ assert parse_form (test_form ) == parse_expected (
343
+ "bootstrap4/test_layout_objects/test_tab_and_tab_holder.html"
319
344
)
320
- assert html .count ("tab-pane" ) == 2
321
-
322
- assert html .count ('class="tab-pane first-tab-class active"' ) == 1
323
-
324
- assert html .count ('<div id="custom-name"' ) == 1
325
- assert html .count ('<div id="two"' ) == 1
326
- assert html .count ('name="first_name"' ) == 1
327
- assert html .count ('name="password1"' ) == 1
328
- assert html .count ('name="password2"' ) == 1
329
345
330
346
def test_tab_helper_reuse (self ):
331
347
# this is a proper form, according to the docs.
0 commit comments