Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partial jsx (expressions) #43

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add test for partial jsx (expressions)
giuseppeg committed Dec 19, 2016
commit 9773e8eb2a873a174356f6d49144c11434bdab17
20 changes: 20 additions & 0 deletions test/fixtures/partials.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default class {
renderTest() {
return <p>test</p>
}

render () {
const test = <div>{this.renderTest}</div>

return (
<div>
{test}
<style jsx>{`
p {
color: red;
}
`}</style>
</div>
)
}
}
18 changes: 18 additions & 0 deletions test/fixtures/partials.out.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import _JSXStyle from "styled-jsx/style";

export default class {
renderTest() {
return <p data-jsx={"1891769468"}>test</p>
}

render () {
const test = <div data-jsx={"1891769468"}>{this.renderTest}</div>

return (
<div data-jsx={"1891769468"}>
{test}
<_JSXStyle css={"p[data-jsx=\"1891769468\"] {color: red;}"} data-jsx={"1891769468"} />
</div>
)
}
}
7 changes: 7 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -59,3 +59,10 @@ test('generates source maps', async t => {
const out = await read('./fixtures/source-maps.out.js')
t.is(code, out.trim())
})

test('works with partial jsx (expressions)', async t => {
const {code} = await transform('./fixtures/partials.js')
const out = await read('./fixtures/partials.out.js')
t.is(code, out.trim())
})