File tree 2 files changed +16
-14
lines changed
2 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -78,14 +78,14 @@ class App extends React.Component {
78
78
}}
79
79
>
80
80
{({ small, medium }) => (
81
- < div>
82
- < p > This always shows. < / p >
83
- small && (
84
- < p > The document is at least 300px wide. < / p >
85
- )
86
- medium && (
87
- < p > The document is at least 600px wide. < / p >
88
- )
81
+ < div
82
+ className = {[
83
+ (small ? ' hello ' : ' ' ),
84
+ (medium ? ' goodbye ' : ' ' ),
85
+ ]. join ( ' ' )}
86
+ >
87
+ At 300px wide, I have a ` className ` of ` hello ` . At 600px wide,
88
+ I have a ` className ` of ` hello goodbye ` .
89
89
< / div>
90
90
)}
91
91
< / Media>
Original file line number Diff line number Diff line change @@ -102,21 +102,23 @@ describe('A <Media>', () => {
102
102
const element = (
103
103
< Media queries = { queries } >
104
104
{ ( { sm, md } ) => (
105
- < div >
106
- { md && 'goodbye' }
107
- { sm && 'hello' }
108
- </ div >
105
+ < div
106
+ className = { [
107
+ ( md ? 'goodbye' : '' ) ,
108
+ ( sm ? 'hello' : '' ) ,
109
+ ] . join ( ' ' ) }
110
+ />
109
111
) }
110
112
</ Media >
111
113
)
112
114
113
115
render ( element , node , ( ) => {
114
- expect ( node . firstChild . innerHTML ) . toMatch ( / h e l l o / )
116
+ expect ( node . firstChild . classList . contains ( 'hello' ) ) . toBe ( true )
117
+ expect ( node . firstChild . classList . contains ( 'goodbye' ) ) . toBe ( false )
115
118
} )
116
119
} )
117
120
} )
118
121
119
-
120
122
} )
121
123
122
124
describe ( 'with a query that does not match' , ( ) => {
You can’t perform that action at this time.
0 commit comments