@@ -5,8 +5,8 @@ import { suppressConsoleLogs } from '../test-utils/suppress-console-logs'
5
5
import { render , Features , PropsForFeatures } from './render'
6
6
import { Props , Expand } from '../types'
7
7
8
- function contents ( ) {
9
- return prettyDOM ( getByTestId ( document . body , 'wrapper' ) , undefined , {
8
+ function contents ( id = 'wrapper' ) {
9
+ return prettyDOM ( getByTestId ( document . body , id ) , undefined , {
10
10
highlight : false ,
11
11
} )
12
12
}
@@ -29,6 +29,22 @@ describe('Default functionality', () => {
29
29
)
30
30
}
31
31
32
+ function DummyWithClassName < TTag extends ElementType = 'div' > (
33
+ props : Props < TTag > & Partial < { className : string | ( ( ) => string ) } >
34
+ ) {
35
+ return (
36
+ < div data-testid = "wrapper-with-class" >
37
+ { render ( {
38
+ ourProps : { } ,
39
+ theirProps : props ,
40
+ slot,
41
+ defaultTag : 'div' ,
42
+ name : 'Dummy' ,
43
+ } ) }
44
+ </ div >
45
+ )
46
+ }
47
+
32
48
it ( 'should be possible to render a dummy component' , ( ) => {
33
49
testRender ( < Dummy /> )
34
50
@@ -41,6 +57,46 @@ describe('Default functionality', () => {
41
57
` )
42
58
} )
43
59
60
+ it ( 'should be possible to merge classes when rendering' , ( ) => {
61
+ testRender (
62
+ < DummyWithClassName as = { Fragment } className = "test-outer" >
63
+ < div className = "test-inner" > </ div >
64
+ </ DummyWithClassName >
65
+ )
66
+
67
+ expect ( contents ( 'wrapper-with-class' ) ) . toMatchInlineSnapshot ( `
68
+ "<div
69
+ data-testid=\\"wrapper-with-class\\"
70
+ >
71
+ <div
72
+ class=\\"test-inner test-outer\\"
73
+ />
74
+ </div>"
75
+ ` )
76
+ } )
77
+
78
+ it ( 'should be possible to merge class fns when rendering' , ( ) => {
79
+ testRender (
80
+ < DummyWithClassName as = { Fragment } className = "test-outer" >
81
+ < Dummy className = { ( ) => 'test-inner' } > </ Dummy >
82
+ </ DummyWithClassName >
83
+ )
84
+
85
+ expect ( contents ( 'wrapper-with-class' ) ) . toMatchInlineSnapshot ( `
86
+ "<div
87
+ data-testid=\\"wrapper-with-class\\"
88
+ >
89
+ <div
90
+ data-testid=\\"wrapper\\"
91
+ >
92
+ <div
93
+ class=\\"test-inner test-outer\\"
94
+ />
95
+ </div>
96
+ </div>"
97
+ ` )
98
+ } )
99
+
44
100
it ( 'should be possible to render a dummy component with some children as a callback' , ( ) => {
45
101
expect . assertions ( 2 )
46
102
0 commit comments