@@ -24,7 +24,7 @@ test(`renders with class ${styles.truncate}`, () => {
2424
2525 const test = screen . getByLabelText ( 'test-id' ) ;
2626
27- expect ( test ) . toHaveClass ( styles . truncate ) ;
27+ expect ( test ) . toHaveClass ( styles . truncate , { exact : true } ) ;
2828} ) ;
2929
3030test ( 'renders with custom class name passed via prop' , ( ) => {
@@ -150,22 +150,16 @@ test('renders with inherited element props spread to the component', () => {
150150} ) ;
151151
152152describe ( 'Truncation with maxCharsDisplayed' , ( ) => {
153- test ( `Does not render with class class-tbd when maxCharsDisplayed is not passed` , ( ) => {
154- render ( < Truncate data-testid = "truncate-component" content = "Test content" /> ) ;
155-
156- expect ( screen . getByText ( 'Test content' ) ) . not . toHaveClass ( 'class-tbd' ) ;
157- } ) ;
158-
159153 test ( `Does not render with class class-tbd when maxCharsDisplayed is 0` , ( ) => {
160154 render ( < Truncate maxCharsDisplayed = { 0 } data-testid = "truncate-component" content = "Test content" /> ) ;
161155
162- expect ( screen . getByText ( 'Test content ') ) . not . toHaveClass ( 'class-tbd' ) ;
156+ expect ( screen . getByTestId ( 'truncate-component ') ) . not . toHaveClass ( 'class-tbd' ) ;
163157 } ) ;
164158
165159 test ( `Renders with class class-tbd when maxCharsDisplayed is greater than 0` , ( ) => {
166160 render ( < Truncate maxCharsDisplayed = { 1 } data-testid = "truncate-component" content = "Test content" /> ) ;
167161
168- expect ( screen . getByText ( 'T ') ) . toHaveClass ( 'class-tbd' ) ;
162+ expect ( screen . getByTestId ( 'truncate-component ') ) . toHaveClass ( 'class-tbd' ) ;
169163 } ) ;
170164
171165 test ( 'Renders with hidden truncated content at end by default when maxCharsDisplayed is passed' , ( ) => {
@@ -176,17 +170,11 @@ describe('Truncation with maxCharsDisplayed', () => {
176170 } ) ;
177171
178172 test ( 'Renders with hidden truncated content at middle position when maxCharsDisplayed is passed and position="middle"' , ( ) => {
179- render (
180- < Truncate
181- data-testid = "truncate-component"
182- position = "middle"
183- content = "Middle position contents being truncated"
184- maxCharsDisplayed = { 10 }
185- />
186- ) ;
187-
188- expect ( screen . getByTestId ( 'truncate-component' ) ) . not . toHaveClass ( 'pf-v6-screen-reader' ) ;
173+ render ( < Truncate position = "middle" content = "Middle position contents being truncated" maxCharsDisplayed = { 10 } /> ) ;
174+
175+ expect ( screen . getByText ( 'Middl' ) ) . not . toHaveClass ( 'pf-v6-screen-reader' ) ;
189176 expect ( screen . getByText ( 'e position contents being trun' ) ) . toHaveClass ( 'pf-v6-screen-reader' ) ;
177+ expect ( screen . getByText ( 'cated' ) ) . not . toHaveClass ( 'pf-v6-screen-reader' ) ;
190178 } ) ;
191179
192180 test ( 'Renders with hidden truncated content at start when maxCharsDisplayed is passed and position="start"' , ( ) => {
0 commit comments