@@ -548,4 +548,28 @@ describe("File upload", function () {
548548 expect ( callback . calledOnce ) . to . be . true ;
549549 sinon . assert . calledWith ( callback , errRes , null ) ;
550550 } ) ;
551+
552+ it ( "With checks option" , function ( done ) {
553+ const fileOptions = {
554+ fileName : "test_file_name" ,
555+ file : "test_file_content" ,
556+ checks : "'request.folder' : '/'" ,
557+ } ;
558+
559+ var callback = sinon . spy ( ) ;
560+
561+ const scope = nock ( "https://upload.imagekit.io/api" )
562+ . post ( "/v1/files/upload" )
563+ . basicAuth ( { user : initializationParams . privateKey , pass : "" } )
564+ . reply ( 200 , function ( uri , requestBody ) {
565+ expect ( this . req . headers [ "content-type" ] ) . include ( "multipart/form-data; boundary=---------------------" ) ;
566+ var boundary = this . req . headers [ "content-type" ] . replace ( "multipart/form-data; boundary=" , "" ) ;
567+ checkFormData ( { requestBody, boundary, fieldName : "fileName" , fieldValue : fileOptions . fileName } ) ;
568+ checkFormData ( { requestBody, boundary, fieldName : "file" , fieldValue : fileOptions . file } ) ;
569+ checkFormData ( { requestBody, boundary, fieldName : "checks" , fieldValue : fileOptions . checks } ) ;
570+ done ( ) ;
571+ } ) ;
572+
573+ imagekit . upload ( fileOptions , callback ) ;
574+ } ) ;
551575} ) ;
0 commit comments