File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,12 +9,7 @@ export const uploadAvatarEndpoint = taggedEndpointsFactory.build({
99 description : "Handles a file upload." ,
1010 input : z
1111 . object ( {
12- avatar : ez . upload ( ) . refine (
13- ( file ) => file . mimetype . match ( / i m a g e \/ .+ / ) ,
14- ( file ) => ( {
15- message : `Should be an image, received ${ file . mimetype } ` ,
16- } ) ,
17- ) ,
12+ avatar : ez . upload ( ) ,
1813 } )
1914 . passthrough ( ) ,
2015 output : z . object ( {
Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ describe("Example", async () => {
196196 const data = new FormData ( ) ;
197197 data . append (
198198 "avatar" ,
199- new Blob ( [ logo ] , { type : "image/svg+xml" } ) ,
199+ new Blob ( [ logo ] , { type : "image/svg+xml" } ) , // FormData mime is buggy in Node 18.0.0
200200 filename ,
201201 ) ;
202202 data . append ( "str" , "test string value" ) ;
@@ -209,7 +209,26 @@ describe("Example", async () => {
209209 { method : "POST" , body : data } ,
210210 ) ;
211211 const json = await response . json ( ) ;
212- expect ( json ) . toMatchSnapshot ( ) ;
212+ expect ( json ) . toEqual ( {
213+ data : {
214+ hash : "f39beeff92379dc935586d726211c2620be6f879" ,
215+ mime :
216+ process . versions . node === "18.0.0"
217+ ? "application/octet-stream" // Node 18.0.0 FormData bug // @todo remove it when dropped
218+ : "image/svg+xml" ,
219+ name : "logo.svg" ,
220+ otherInputs : {
221+ arr : [ "456" , "789" ] ,
222+ num : "123" ,
223+ obj : {
224+ some : "thing" ,
225+ } ,
226+ str : "test string value" ,
227+ } ,
228+ size : 48687 ,
229+ } ,
230+ status : "success" ,
231+ } ) ;
213232 } ) ;
214233
215234 test . each ( [ readFileSync ( "logo.svg" ) , createReadStream ( "logo.svg" ) ] ) (
You can’t perform that action at this time.
0 commit comments