File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,35 @@ const uploadSuccessResponseObj = {
2626 "fileType" : "image"
2727} ;
2828
29+ describe ( "File upload custom endpoint" , function ( ) {
30+ var imagekit = new ImageKit ( {
31+ ...initializationParams ,
32+ uploadEndpoint : "https://custom-env.imagekit.io/api/v1/files/upload"
33+ } ) ;
34+
35+ it ( 'Upload endpoint test case' , function ( done ) {
36+ const fileOptions = {
37+ fileName : "test_file_name" ,
38+ file : "test_file_content"
39+ } ;
40+
41+ var callback = sinon . spy ( ) ;
42+
43+ const scope = nock ( 'https://custom-env.imagekit.io/api' )
44+ . post ( '/v1/files/upload' )
45+ . basicAuth ( { user : initializationParams . privateKey , pass : '' } )
46+ . reply ( 200 , uploadSuccessResponseObj )
47+
48+ imagekit . upload ( fileOptions , callback ) ;
49+
50+ setTimeout ( ( ) => {
51+ expect ( callback . calledOnce ) . to . be . true ;
52+ sinon . assert . calledWith ( callback , null , uploadSuccessResponseObj ) ;
53+ done ( ) ;
54+ } , 10 ) ;
55+ } ) ;
56+ } ) ;
57+
2958describe ( "File upload" , function ( ) {
3059 var imagekit = new ImageKit ( initializationParams ) ;
3160
You can’t perform that action at this time.
0 commit comments