@@ -24,7 +24,7 @@ test(`renders with class ${styles.truncate}`, () => {
24
24
25
25
const test = screen . getByLabelText ( 'test-id' ) ;
26
26
27
- expect ( test ) . toHaveClass ( styles . truncate ) ;
27
+ expect ( test ) . toHaveClass ( styles . truncate , { exact : true } ) ;
28
28
} ) ;
29
29
30
30
test ( 'renders with custom class name passed via prop' , ( ) => {
@@ -150,22 +150,16 @@ test('renders with inherited element props spread to the component', () => {
150
150
} ) ;
151
151
152
152
describe ( '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
-
159
153
test ( `Does not render with class class-tbd when maxCharsDisplayed is 0` , ( ) => {
160
154
render ( < Truncate maxCharsDisplayed = { 0 } data-testid = "truncate-component" content = "Test content" /> ) ;
161
155
162
- expect ( screen . getByText ( 'Test content ') ) . not . toHaveClass ( 'class-tbd' ) ;
156
+ expect ( screen . getByTestId ( 'truncate-component ') ) . not . toHaveClass ( 'class-tbd' ) ;
163
157
} ) ;
164
158
165
159
test ( `Renders with class class-tbd when maxCharsDisplayed is greater than 0` , ( ) => {
166
160
render ( < Truncate maxCharsDisplayed = { 1 } data-testid = "truncate-component" content = "Test content" /> ) ;
167
161
168
- expect ( screen . getByText ( 'T ') ) . toHaveClass ( 'class-tbd' ) ;
162
+ expect ( screen . getByTestId ( 'truncate-component ') ) . toHaveClass ( 'class-tbd' ) ;
169
163
} ) ;
170
164
171
165
test ( 'Renders with hidden truncated content at end by default when maxCharsDisplayed is passed' , ( ) => {
@@ -176,17 +170,11 @@ describe('Truncation with maxCharsDisplayed', () => {
176
170
} ) ;
177
171
178
172
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' ) ;
189
176
expect ( screen . getByText ( 'e position contents being trun' ) ) . toHaveClass ( 'pf-v6-screen-reader' ) ;
177
+ expect ( screen . getByText ( 'cated' ) ) . not . toHaveClass ( 'pf-v6-screen-reader' ) ;
190
178
} ) ;
191
179
192
180
test ( 'Renders with hidden truncated content at start when maxCharsDisplayed is passed and position="start"' , ( ) => {
0 commit comments