Skip to content

Commit 193c01c

Browse files
authored
Merge pull request #58 from VinSpee/update-queries-test
Update queries test
2 parents b863f5a + 9009380 commit 193c01c

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

Diff for: README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ class App extends React.Component {
7878
}}
7979
>
8080
{({ 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`.
8989
</div>
9090
)}
9191
</Media>

Diff for: modules/__tests__/Media-test.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,23 @@ describe('A <Media>', () => {
102102
const element = (
103103
<Media queries={queries}>
104104
{({ 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+
/>
109111
)}
110112
</Media>
111113
)
112114

113115
render(element, node, () => {
114-
expect(node.firstChild.innerHTML).toMatch(/hello/)
116+
expect(node.firstChild.classList.contains('hello')).toBe(true)
117+
expect(node.firstChild.classList.contains('goodbye')).toBe(false)
115118
})
116119
})
117120
})
118121

119-
120122
})
121123

122124
describe('with a query that does not match', () => {

0 commit comments

Comments
 (0)