-
Notifications
You must be signed in to change notification settings - Fork 26k
/
parse-page-runtime.test.ts
45 lines (39 loc) · 1.3 KB
/
parse-page-runtime.test.ts
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
import { getPageRuntime } from 'next/dist/build/entries'
import { join } from 'path'
const fixtureDir = join(__dirname, 'fixtures')
describe('parse page runtime config', () => {
it('should parse nodejs runtime correctly', async () => {
const runtime = await getPageRuntime(
join(fixtureDir, 'page-runtime/nodejs.js')
)
expect(runtime).toBe('nodejs')
})
it('should parse edge runtime correctly', async () => {
const runtime = await getPageRuntime(
join(fixtureDir, 'page-runtime/edge.js')
)
expect(runtime).toBe('edge')
})
it('should return undefined if no runtime is specified', async () => {
const runtime = await getPageRuntime(
join(fixtureDir, 'page-runtime/static.js')
)
expect(runtime).toBe(undefined)
})
})
describe('fallback to the global runtime configuration', () => {
it('should fallback when gSP is defined and exported', async () => {
const runtime = await getPageRuntime(
join(fixtureDir, 'page-runtime/fallback-with-gsp.js'),
'edge'
)
expect(runtime).toBe('edge')
})
it('should fallback when gSP is re-exported from other module', async () => {
const runtime = await getPageRuntime(
join(fixtureDir, 'page-runtime/fallback-re-export-gsp.js'),
'edge'
)
expect(runtime).toBe('edge')
})
})