@@ -8,6 +8,7 @@ describe('buildRequest', () => {
8
8
[ ] ,
9
9
{ firstName : 'Kevin' } ,
10
10
{ 'child-component' : { fingerprint : '123' , tag : 'div' } } ,
11
+ { } ,
11
12
{ }
12
13
) ;
13
14
@@ -28,17 +29,20 @@ describe('buildRequest', () => {
28
29
} ] ,
29
30
{ firstName : 'Kevin' } ,
30
31
{ 'child-component' : { fingerprint : '123' , tag : 'div' } } ,
32
+ { } ,
31
33
{ }
32
34
) ;
33
35
34
36
expect ( url ) . toEqual ( '/_components/saveData' ) ;
35
37
expect ( fetchOptions . method ) . toEqual ( 'POST' ) ;
36
38
expect ( fetchOptions . headers ) . toEqual ( {
37
39
Accept : 'application/vnd.live-component+html' ,
38
- 'Content-Type' : 'application/json' ,
39
40
'X-CSRF-TOKEN' : '_the_csrf_token' ,
40
41
} ) ;
41
- expect ( fetchOptions . body ) . toEqual ( JSON . stringify ( {
42
+ const body = fetchOptions . body ;
43
+ expect ( body ) . toBeInstanceOf ( FormData ) ;
44
+ // @ts -ignore body is already asserted to be FormData
45
+ expect ( body . get ( 'data' ) ) . toEqual ( JSON . stringify ( {
42
46
props : { firstName : 'Ryan' } ,
43
47
updated : { firstName : 'Kevin' } ,
44
48
children : { 'child-component' : { fingerprint : '123' , tag : 'div' } } ,
@@ -59,12 +63,16 @@ describe('buildRequest', () => {
59
63
} ] ,
60
64
{ firstName : 'Kevin' } ,
61
65
{ } ,
66
+ { } ,
62
67
{ }
63
68
) ;
64
69
65
70
expect ( url ) . toEqual ( '/_components/_batch' ) ;
66
71
expect ( fetchOptions . method ) . toEqual ( 'POST' ) ;
67
- expect ( fetchOptions . body ) . toEqual ( JSON . stringify ( {
72
+ const body = fetchOptions . body ;
73
+ expect ( body ) . toBeInstanceOf ( FormData ) ;
74
+ // @ts -ignore body is already asserted to be FormData
75
+ expect ( body . get ( 'data' ) ) . toEqual ( JSON . stringify ( {
68
76
props : { firstName : 'Ryan' } ,
69
77
updated : { firstName : 'Kevin' } ,
70
78
actions : [ {
@@ -85,6 +93,7 @@ describe('buildRequest', () => {
85
93
[ ] ,
86
94
{ firstName : 'Kevin' . repeat ( 1000 ) } ,
87
95
{ } ,
96
+ { } ,
88
97
{ }
89
98
) ;
90
99
@@ -93,9 +102,11 @@ describe('buildRequest', () => {
93
102
expect ( fetchOptions . headers ) . toEqual ( {
94
103
// no token
95
104
Accept : 'application/vnd.live-component+html' ,
96
- 'Content-Type' : 'application/json' ,
97
105
} ) ;
98
- expect ( fetchOptions . body ) . toEqual ( JSON . stringify ( {
106
+ const body = fetchOptions . body ;
107
+ expect ( body ) . toBeInstanceOf ( FormData ) ;
108
+ // @ts -ignore body is already asserted to be FormData
109
+ expect ( body . get ( 'data' ) ) . toEqual ( JSON . stringify ( {
99
110
props : { firstName : 'Ryan' . repeat ( 1000 ) } ,
100
111
updated : { firstName : 'Kevin' . repeat ( 1000 ) } ,
101
112
} ) ) ;
@@ -108,7 +119,8 @@ describe('buildRequest', () => {
108
119
[ ] ,
109
120
{ firstName : 'Kevin' } ,
110
121
{ } ,
111
- { count : 5 }
122
+ { count : 5 } ,
123
+ { }
112
124
) ;
113
125
114
126
expect ( url ) . toEqual ( '/_components?existing_param=1&props=%7B%22firstName%22%3A%22Ryan%22%7D&updated=%7B%22firstName%22%3A%22Kevin%22%7D&propsFromParent=%7B%22count%22%3A5%7D' ) ;
@@ -123,9 +135,13 @@ describe('buildRequest', () => {
123
135
{ firstName : 'Kevin' } ,
124
136
{ } ,
125
137
{ count : 5 } ,
138
+ { }
126
139
) ;
127
140
128
- expect ( fetchOptions . body ) . toEqual ( JSON . stringify ( {
141
+ const body = fetchOptions . body ;
142
+ expect ( body ) . toBeInstanceOf ( FormData ) ;
143
+ // @ts -ignore body is already asserted to be FormData
144
+ expect ( body . get ( 'data' ) ) . toEqual ( JSON . stringify ( {
129
145
props : { firstName : 'Ryan' } ,
130
146
updated : { firstName : 'Kevin' } ,
131
147
propsFromParent : { count : 5 } ,
0 commit comments