forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app-router-headers.test.ts
95 lines (91 loc) · 1.7 KB
/
app-router-headers.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
import { escapeFlightRouterState } from 'next/client/components/app-router-headers'
import { FlightRouterState } from 'next/server/app-render'
const state1: FlightRouterState = [
'',
{
children: [
['slug', 'свитер-urbain', 'd'],
{
children: ['', {}],
},
],
},
null,
'refetch',
]
const state1Escaped: FlightRouterState = [
'',
{
children: [
['slug', '%D1%81%D0%B2%D0%B8%D1%82%D0%B5%D1%80-urbain', 'd'],
{
children: ['', {}],
},
],
},
null,
'refetch',
]
const state2: FlightRouterState = [
'',
{
children: [
['slug', 'свитер-urbain', 'd'],
{
children: ['', {}],
},
],
},
null,
null,
true,
]
const state2Escaped: FlightRouterState = [
'',
{
children: [
['slug', '%D1%81%D0%B2%D0%B8%D1%82%D0%B5%D1%80-urbain', 'd'],
{
children: ['', {}],
},
],
},
null,
null,
true,
]
const state3: FlightRouterState = [
'',
{
children: [
['slug', 'свитер-urbain', 'd'],
{
children: ['', {}],
},
null,
'refetch',
],
},
]
const state3Escaped: FlightRouterState = [
'',
{
children: [
['slug', '%D1%81%D0%B2%D0%B8%D1%82%D0%B5%D1%80-urbain', 'd'],
{
children: ['', {}],
},
null,
'refetch',
],
},
]
describe('escapeFlightRouterState', () => {
it.each([
{ state: state1, escapedState: state1Escaped },
{ state: state2, escapedState: state2Escaped },
{ state: state3, escapedState: state3Escaped },
])('should escape non-iso segment value', ({ state, escapedState }) => {
expect(escapeFlightRouterState(state)).toMatchObject(escapedState)
})
})