File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,21 @@ const shouldDive = node =>
5
5
6
6
const isTagWithClassName = node =>
7
7
node . exists ( ) && node . prop ( "className" ) && typeof node . type ( ) === "string" ;
8
+
9
+ const hasClassName = node =>
10
+ node . length > 0
11
+ && typeof node . props === "function"
12
+ && node . props ( "className" )
13
+ && node . props ( "className" ) . className ;
8
14
9
15
const getClassNames = received => {
10
16
let className ;
11
17
12
18
if ( received ) {
13
19
if ( received . $$typeof === Symbol . for ( "react.test.json" ) ) {
14
20
className = received . props . className || received . props . class ;
21
+ } else if ( hasClassName ( received ) ) {
22
+ className = received . props ( "className" ) . className ;
15
23
} else if ( typeof received . exists === "function" && received . exists ( ) ) {
16
24
const tree = shouldDive ( received ) ? received . dive ( ) : received ;
17
25
const components = tree . findWhere ( isTagWithClassName ) ;
Original file line number Diff line number Diff line change @@ -479,6 +479,19 @@ it("nested", () => {
479
479
toHaveStyleRule ( < MyComponent /> , "background" , "papayawhip" ) ;
480
480
} ) ;
481
481
482
+ it ( "nested with styling" , ( ) => {
483
+ const Wrapper = styled . section `
484
+ background: papayawhip;
485
+ ` ;
486
+
487
+ const MyComponent = ( props ) => < Wrapper { ...props } /> ;
488
+ const MyStyledComponent = styled ( MyComponent ) `
489
+ color: red;
490
+ ` ;
491
+
492
+ toHaveStyleRule ( < MyStyledComponent /> , "color" , "red" ) ;
493
+ } ) ;
494
+
482
495
it ( "empty children" , ( ) => {
483
496
const Wrapper = styled . section `
484
497
padding: 4em;
You can’t perform that action at this time.
0 commit comments