1+ import '@testing-library/jest-dom' ;
2+ // eslint-disable-next-line no-restricted-imports -- React in scope required for TS (test file)
3+ import React from 'react' ;
14import { render , screen } from '@testing-library/react' ;
25
36import { Accordion } from '../Accordion' ;
47import { AccordionContext } from '../AccordionContext' ;
8+ // @ts -ignore - react-styles subpath module resolution
59import styles from '@patternfly/react-styles/css/components/Accordion/accordion' ;
610
711test ( 'Renders without children' , ( ) => {
@@ -33,7 +37,7 @@ test('Renders with inherited element props spread to the component', () => {
3337 expect ( screen . getByText ( 'Test' ) ) . toHaveAccessibleName ( 'Label' ) ;
3438} ) ;
3539
36- test ( `Renders with class name ${ styles . accordion } ` , ( ) => {
40+ test ( `Renders with class ${ styles . accordion } ` , ( ) => {
3741 render ( < Accordion > Test</ Accordion > ) ;
3842
3943 expect ( screen . getByText ( 'Test' ) ) . toHaveClass ( styles . accordion ) ;
@@ -62,7 +66,7 @@ test('Renders Accordion as a "div" when asDefinitionList is false', () => {
6266test ( 'Provides a ContentContainer of "dd" in a context by default' , ( ) => {
6367 render (
6468 < Accordion >
65- < AccordionContext . Consumer > { ( { ContentContainer } ) => ContentContainer } </ AccordionContext . Consumer >
69+ < AccordionContext . Consumer > { ( { ContentContainer } ) => String ( ContentContainer ) } </ AccordionContext . Consumer >
6670 </ Accordion >
6771 ) ;
6872
@@ -72,7 +76,7 @@ test('Provides a ContentContainer of "dd" in a context by default', () => {
7276test ( 'Provides a ContentContainer of "div" in a context when asDefinitionList is false' , ( ) => {
7377 render (
7478 < Accordion asDefinitionList = { false } >
75- < AccordionContext . Consumer > { ( { ContentContainer } ) => ContentContainer } </ AccordionContext . Consumer >
79+ < AccordionContext . Consumer > { ( { ContentContainer } ) => String ( ContentContainer ) } </ AccordionContext . Consumer >
7680 </ Accordion >
7781 ) ;
7882
@@ -82,7 +86,7 @@ test('Provides a ContentContainer of "div" in a context when asDefinitionList is
8286test ( 'Provides a ToggleContainer of "dt" in a context by default' , ( ) => {
8387 render (
8488 < Accordion >
85- < AccordionContext . Consumer > { ( { ToggleContainer } ) => ToggleContainer } </ AccordionContext . Consumer >
89+ < AccordionContext . Consumer > { ( { ToggleContainer } ) => String ( ToggleContainer ) } </ AccordionContext . Consumer >
8690 </ Accordion >
8791 ) ;
8892
@@ -92,7 +96,7 @@ test('Provides a ToggleContainer of "dt" in a context by default', () => {
9296test ( 'Provides a ToggleContainer of "h3" in a context when asDefinitionList is false' , ( ) => {
9397 render (
9498 < Accordion asDefinitionList = { false } >
95- < AccordionContext . Consumer > { ( { ToggleContainer } ) => ToggleContainer } </ AccordionContext . Consumer >
99+ < AccordionContext . Consumer > { ( { ToggleContainer } ) => String ( ToggleContainer ) } </ AccordionContext . Consumer >
96100 </ Accordion >
97101 ) ;
98102
@@ -102,7 +106,7 @@ test('Provides a ToggleContainer of "h3" in a context when asDefinitionList is f
102106test ( 'Provides a ToggleContainer of "h2" in a context when asDefinitionList is false and headingLevel is "h2"' , ( ) => {
103107 render (
104108 < Accordion asDefinitionList = { false } headingLevel = "h2" >
105- < AccordionContext . Consumer > { ( { ToggleContainer } ) => ToggleContainer } </ AccordionContext . Consumer >
109+ < AccordionContext . Consumer > { ( { ToggleContainer } ) => String ( ToggleContainer ) } </ AccordionContext . Consumer >
106110 </ Accordion >
107111 ) ;
108112
@@ -121,6 +125,38 @@ test('Renders with pf-m-bordered when isBordered=true', () => {
121125 expect ( screen . getByText ( 'Test' ) ) . toHaveClass ( 'pf-m-bordered' ) ;
122126} ) ;
123127
128+ test ( `Renders without class ${ styles . modifiers . noPlain } by default` , ( ) => {
129+ render ( < Accordion > Test</ Accordion > ) ;
130+
131+ expect ( screen . getByText ( 'Test' ) ) . not . toHaveClass ( styles . modifiers . noPlain ) ;
132+ } ) ;
133+
134+ test ( `Renders without class ${ styles . modifiers . noPlain } when isPlain is undefined` , ( ) => {
135+ render ( < Accordion isPlain = { undefined } > Test</ Accordion > ) ;
136+
137+ expect ( screen . getByText ( 'Test' ) ) . not . toHaveClass ( styles . modifiers . noPlain ) ;
138+ } ) ;
139+
140+ test ( `Renders without class ${ styles . modifiers . noPlain } when isPlain=false and glass theme is not applied` , ( ) => {
141+ render ( < Accordion isPlain = { false } > Test</ Accordion > ) ;
142+
143+ expect ( screen . getByText ( 'Test' ) ) . not . toHaveClass ( styles . modifiers . noPlain ) ;
144+ } ) ;
145+
146+ test ( `Renders with class ${ styles . modifiers . noPlain } when isPlain=false and glass theme is applied` , ( ) => {
147+ document . documentElement . classList . add ( 'pf-v6-theme-glass' ) ;
148+ render ( < Accordion isPlain = { false } > Test</ Accordion > ) ;
149+
150+ expect ( screen . getByText ( 'Test' ) ) . toHaveClass ( styles . modifiers . noPlain ) ;
151+ document . documentElement . classList . remove ( 'pf-v6-theme-glass' ) ;
152+ } ) ;
153+
154+ test ( `Renders without class ${ styles . modifiers . noPlain } when isPlain=true` , ( ) => {
155+ render ( < Accordion isPlain > Test</ Accordion > ) ;
156+
157+ expect ( screen . getByText ( 'Test' ) ) . not . toHaveClass ( styles . modifiers . noPlain ) ;
158+ } ) ;
159+
124160test ( 'Renders without pf-m-display-lg by default' , ( ) => {
125161 render ( < Accordion > Test</ Accordion > ) ;
126162
0 commit comments