@@ -15,7 +15,7 @@ test(`Renders default class ${styles.dataListCell}`, () => {
15
15
Primary Id
16
16
</ DataListCell >
17
17
) ;
18
- expect ( screen . getByTestId ( 'test' ) ) . toHaveClass ( styles . dataListCell ) ;
18
+ expect ( screen . getByTestId ( 'test' ) ) . toHaveClass ( styles . dataListCell , { exact : true } ) ;
19
19
} ) ;
20
20
21
21
test ( `Renders custom class when className is passed` , ( ) => {
@@ -27,13 +27,22 @@ test(`Renders custom class when className is passed`, () => {
27
27
expect ( screen . getByTestId ( 'test' ) ) . toHaveClass ( 'test-class' ) ;
28
28
} ) ;
29
29
30
+ test ( `Renders with spread props` , ( ) => {
31
+ render (
32
+ < DataListCell key = { 0 } id = "test" >
33
+ Primary Id
34
+ </ DataListCell >
35
+ ) ;
36
+ expect ( screen . getByText ( 'Primary Id' ) ) . toHaveAttribute ( 'id' , 'test' ) ;
37
+ } ) ;
38
+
30
39
test ( 'Renders width modifier when width is passed' , ( ) => {
31
40
[
32
41
{ width : 1 , class : '' } ,
33
- { width : 2 , class : 'pf-m-flex-2' } ,
34
- { width : 3 , class : 'pf-m-flex-3' } ,
35
- { width : 4 , class : 'pf-m-flex-4' } ,
36
- { width : 5 , class : 'pf-m-flex-5' }
42
+ { width : 2 , class : styles . modifiers . flex_2 } ,
43
+ { width : 3 , class : styles . modifiers . flex_3 } ,
44
+ { width : 4 , class : styles . modifiers . flex_4 } ,
45
+ { width : 5 , class : styles . modifiers . flex_5 }
37
46
] . forEach ( ( testCase , index ) => {
38
47
const testId = `cell-test-id-${ index } ` ;
39
48
@@ -46,17 +55,22 @@ test('Renders width modifier when width is passed', () => {
46
55
const dataListCell = screen . getByTestId ( testId ) ;
47
56
48
57
testCase . class === ''
49
- ? expect ( dataListCell ) . toHaveClass ( 'pf-v5-c-data-list__cell' , { exact : true } )
58
+ ? expect ( dataListCell ) . not . toHaveClass (
59
+ styles . modifiers . flex_2 ,
60
+ styles . modifiers . flex_3 ,
61
+ styles . modifiers . flex_4 ,
62
+ styles . modifiers . flex_5
63
+ )
50
64
: expect ( dataListCell ) . toHaveClass ( `pf-v5-c-data-list__cell ${ testCase . class } ` , { exact : true } ) ;
51
65
} ) ;
52
66
} ) ;
53
67
54
68
test ( 'Has text wrap modifiers when wrapModifier is passed' , ( ) => {
55
69
[
56
70
{ wrapModifier : null as any , class : '' } ,
57
- { wrapModifier : 'breakWord' , class : 'pf-m-break-word' } ,
58
- { wrapModifier : 'nowrap' , class : 'pf-m- nowrap' } ,
59
- { wrapModifier : 'truncate' , class : 'pf-m- truncate' }
71
+ { wrapModifier : 'breakWord' , class : styles . modifiers . breakWord } ,
72
+ { wrapModifier : 'nowrap' , class : styles . modifiers . nowrap } ,
73
+ { wrapModifier : 'truncate' , class : styles . modifiers . truncate }
60
74
] . forEach ( ( testCase , index ) => {
61
75
const testId = `cell-test-id-${ index } ` ;
62
76
@@ -69,8 +83,12 @@ test('Has text wrap modifiers when wrapModifier is passed', () => {
69
83
const dataListCell = screen . getByTestId ( testId ) ;
70
84
71
85
testCase . class === ''
72
- ? expect ( dataListCell ) . toHaveClass ( 'pf-v5-c-data-list__cell' )
73
- : expect ( dataListCell ) . toHaveClass ( `pf-v5-c-data-list__cell ${ testCase . class } ` ) ;
86
+ ? expect ( dataListCell ) . not . toHaveClass (
87
+ styles . modifiers . breakWord ,
88
+ styles . modifiers . nowrap ,
89
+ styles . modifiers . truncate
90
+ )
91
+ : expect ( dataListCell ) . toHaveClass ( `${ testCase . class } ` ) ;
74
92
} ) ;
75
93
} ) ;
76
94
0 commit comments