Commit ee18967d authored by Joe Haddad's avatar Joe Haddad Committed by Tim Neutkens

Add tests for AMP style tags (#6355)

Relevant commit: https://github.com/zeit/next.js/commit/f913aabe163aebfbe57a2c407be5e7108559cc3a

~~I needed to upgrade Standard to work with JSX fragment syntax.~~ This caused too much noise so I just stopped using Fragments.
parent a2f37ba4
export default function Bar () {
return (
<div>
<span>Bar!</span>
<style jsx>{`
span {
color: blue;
}
`}</style>
</div>
)
}
export default function Foo () {
return (
<div>
<div>Foo!</div>
<style jsx>{`
div {
color: red;
}
`}</style>
</div>
)
}
import Foo from '../components/Foo'
import Bar from '../components/Bar'
export default () => (
<div>
<Foo />
<Bar />
<style jsx global>{`
body {
background-color: green;
}
`}</style>
</div>
)
...@@ -135,4 +135,18 @@ describe('AMP Usage', () => { ...@@ -135,4 +135,18 @@ describe('AMP Usage', () => {
).toBe('/use-amp-hook') ).toBe('/use-amp-hook')
}) })
}) })
describe('combined styles', () => {
it('should combine style tags', async () => {
const html = await renderViaHTTP(appPort, '/styled?amp=1')
const $ = cheerio.load(html)
expect(
$('style[amp-custom]')
.first()
.text()
).toMatch(
/div.jsx-\d+{color:red;}span.jsx-\d+{color:blue;}body{background-color:green;}/
)
})
})
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment