File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
test/integration/api/uploader Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -371,7 +371,8 @@ function build_upload_params(options) {
371371 quality_override : options . quality_override ,
372372 accessibility_analysis : utils . as_safe_bool ( options . accessibility_analysis ) ,
373373 use_asset_folder_as_public_id_prefix : utils . as_safe_bool ( options . use_asset_folder_as_public_id_prefix ) ,
374- visual_search : utils . as_safe_bool ( options . visual_search )
374+ visual_search : utils . as_safe_bool ( options . visual_search ) ,
375+ on_success : options . on_success
375376 } ;
376377 return utils . updateable_resource_params ( options , params ) ;
377378}
Original file line number Diff line number Diff line change @@ -652,6 +652,30 @@ describe("uploader", function () {
652652 } ) ;
653653 } ) ;
654654
655+ describe ( 'when passing on_success in parameters' , ( ) => {
656+ var spy , xhr ;
657+ spy = void 0 ;
658+ xhr = void 0 ;
659+ before ( function ( ) {
660+ xhr = sinon . useFakeXMLHttpRequest ( ) ;
661+ spy = sinon . spy ( ClientRequest . prototype , 'write' ) ;
662+ } ) ;
663+ after ( function ( ) {
664+ spy . restore ( ) ;
665+ return xhr . restore ( ) ;
666+ } ) ;
667+
668+ it ( 'should pass its value to the upload api' , ( ) => {
669+ cloudinary . v2 . uploader . upload ( IMAGE_FILE , {
670+ on_success : 'current_asset.update({tags: ["autocaption"]});'
671+ } ) ;
672+
673+ expect ( spy . calledWith ( sinon . match ( ( arg ) => {
674+ return arg . toString ( ) . match ( / o n _ s u c c e s s = ' c u r r e n t _ a s s e t .u p d a t e ( { t a g s : [ " a u t o c a p t i o n " ] } ) ; ' / ) ;
675+ } ) ) ) ;
676+ } ) ;
677+ } ) ;
678+
655679 describe ( "upload_chunked" , function ( ) {
656680 this . timeout ( TIMEOUT . LONG * 10 ) ;
657681 it ( "should specify chunk size" , function ( done ) {
You can’t perform that action at this time.
0 commit comments