-
Notifications
You must be signed in to change notification settings - Fork 26.1k
/
warn-removed-experimental-config.test.ts
98 lines (86 loc) · 2.57 KB
/
warn-removed-experimental-config.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { warnOptionHasBeenMovedOutOfExperimental } from 'next/dist/server/config'
describe('warnOptionHasBeenMovedOutOfExperimental', () => {
let spy: jest.SpyInstance
beforeAll(() => {
spy = jest.spyOn(console, 'warn').mockImplementation(() => {})
})
it('should not log warning message without experimental config', () => {
warnOptionHasBeenMovedOutOfExperimental(
{},
'skipTrailingSlashRedirect',
'skipTrailingSlashRedirect',
'next.config.js'
)
warnOptionHasBeenMovedOutOfExperimental(
{
experimental: {},
},
'skipTrailingSlashRedirect',
'skipTrailingSlashRedirect',
'next.config.js'
)
expect(spy).not.toBeCalled()
})
it('should log warning message with removed experimental config', () => {
warnOptionHasBeenMovedOutOfExperimental(
{
experimental: {
skipTrailingSlashRedirect: true,
},
} as any,
'skipTrailingSlashRedirect',
'skipTrailingSlashRedirect',
'next.config.js'
)
expect(spy).toHaveBeenCalledWith(
expect.stringContaining('warn'),
'`skipTrailingSlashRedirect` has been moved out of `experimental`. Please update your next.config.js file accordingly.'
)
})
it('should log warning message with removed experimental config - complex key', () => {
warnOptionHasBeenMovedOutOfExperimental(
{
experimental: {
relay: true,
},
} as any,
'relay',
'compiler.relay',
'next.config.js'
)
expect(spy).toHaveBeenCalledWith(
expect.stringContaining('warn'),
'`relay` has been moved out of `experimental` and into `compiler.relay`. Please update your next.config.js file accordingly.'
)
})
it('should update removed experimental config into new config', () => {
const config = {
experimental: {
skipTrailingSlashRedirect: true,
},
} as any
warnOptionHasBeenMovedOutOfExperimental(
config,
'skipTrailingSlashRedirect',
'skipTrailingSlashRedirect',
'next.config.js'
)
expect(config.experimental.skipTrailingSlashRedirect).toBe(true)
expect(config.skipTrailingSlashRedirect).toBe(true)
})
it('should update removed experimental config into new config - complex key', () => {
const config = {
experimental: {
foo: 'bar',
},
} as any
warnOptionHasBeenMovedOutOfExperimental(
config,
'foo',
'deep.prop.baz',
'next.config.js'
)
expect(config.experimental.foo).toBe('bar')
expect(config.deep.prop.baz).toBe('bar')
})
})