1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

add a css test

This commit is contained in:
nkzawa 2016-10-10 13:35:37 +09:00
parent 3647ed14ac
commit facd19b5a7
3 changed files with 15 additions and 2 deletions

View file

@ -30,7 +30,7 @@ export function Head (props, context) {
.map((h, i) => React.cloneElement(h, { key: '_next' + i })) .map((h, i) => React.cloneElement(h, { key: '_next' + i }))
return <head> return <head>
{h} {h}
<style data-aphrodite dangerouslySetInnerHTML={{ __html: css.content }} /> <style data-aphrodite="" dangerouslySetInnerHTML={{ __html: css.content }} />
</head> </head>
} }

8
test/fixtures/basic/pages/css.js vendored Normal file
View file

@ -0,0 +1,8 @@
import React from 'react'
import { StyleSheet, css } from 'next/css'
export default () => <div className={css(styles.red)}>This is red</div>
const styles = StyleSheet.create({
red: { color: 'red' }
})

View file

@ -9,10 +9,15 @@ test.before(() => build(dir))
test(async (t) => { test(async (t) => {
const html = await render('/stateless') const html = await render('/stateless')
console.log(html)
t.true(html.includes('<h1>My component!</h1>')) t.true(html.includes('<h1>My component!</h1>'))
}) })
test(async (t) => {
const html = await render('/css')
t.true(html.includes('<style data-aphrodite="">.red_im3wl1{color:red !important;}</style>'))
t.true(html.includes('<div class="red_im3wl1">This is red</div>'))
})
function render (url, ctx) { function render (url, ctx) {
return _render(url, ctx, { dir, staticMarkup: true }) return _render(url, ctx, { dir, staticMarkup: true })
} }