forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
69 lines (57 loc) · 1.59 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* eslint-env jest */
import { join } from 'path'
import webdriver from 'next-webdriver'
import {
killApp,
findPort,
nextStart,
nextBuild,
launchApp,
renderViaHTTP,
} from 'next-test-utils'
const appDir = join(__dirname, '../app')
let appPort
let app
function runTests() {
it('should render styles during CSR', async () => {
const browser = await webdriver(appPort, '/')
const color = await browser.eval(
`getComputedStyle(document.querySelector('button')).color`
)
expect(color).toMatch('0, 255, 255')
})
it('should render styles during CSR (AMP)', async () => {
const browser = await webdriver(appPort, '/amp')
const color = await browser.eval(
`getComputedStyle(document.querySelector('button')).color`
)
expect(color).toMatch('0, 255, 255')
})
it('should render styles during SSR', async () => {
const html = await renderViaHTTP(appPort, '/')
expect(html).toMatch(/color:.*?cyan/)
})
it('should render styles during SSR (AMP)', async () => {
const html = await renderViaHTTP(appPort, '/amp')
expect(html).toMatch(/color:.*?cyan/)
})
}
describe('styled-jsx using in node_modules', () => {
describe('Production', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
runTests()
})
describe('Development', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => killApp(app))
runTests()
})
})