-
Notifications
You must be signed in to change notification settings - Fork 26.1k
/
index.test.js
50 lines (42 loc) · 1.36 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
/* eslint-env jest */
import { join } from 'path'
import {
fetchViaHTTP,
findPort,
killApp,
nextBuild,
nextStart,
} from 'next-test-utils'
import cheerio from 'cheerio'
jest.setTimeout(1000 * 60 * 2)
const appDir = join(__dirname, '..')
let appPort
let app
describe('File Dependencies', () => {
describe('production mode', () => {
beforeAll(async () => {
appPort = await findPort()
await nextBuild(appDir)
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
it('should depend on global and module css files in standard page', async () => {
const res = await fetchViaHTTP(appPort, '/')
const $ = cheerio.load(await res.text())
const cssFiles = $('link[rel="stylesheet"]')
expect(cssFiles.length).toBe(2)
})
it('should depend on global and module css files in 404 page', async () => {
const res = await fetchViaHTTP(appPort, '/__not_found__')
const $ = cheerio.load(await res.text())
const cssFiles = $('link[rel="stylesheet"]')
expect(cssFiles.length).toBe(2)
})
it('should depend on global and module css files in _error page', async () => {
const res = await fetchViaHTTP(appPort, '/error-trigger')
const $ = cheerio.load(await res.text())
const cssFiles = $('link[rel="stylesheet"]')
expect(cssFiles.length).toBe(2)
})
})
})