@@ -421,6 +421,78 @@ describe("cloudinary", function () {
421421 signature : "123515adfa151" ,
422422 } ) ) . to . eql ( "image/upload/v1251251251/abcd.jpg#123515adfa151" ) ;
423423 } ) ;
424+ it ( 'should support custom function of type wasm with a source' , function ( ) {
425+ var options , result ;
426+ options = {
427+ custom_function : { function_type : 'wasm' , source : 'blur.wasm' }
428+ } ;
429+ result = cloudinary . utils . url ( "test" , options ) ;
430+ expect ( options ) . to . eql ( { } ) ;
431+ expect ( result ) . to . eql ( "http://res.cloudinary.com/test123/image/upload/fn_wasm:blur.wasm/test" ) ;
432+ } ) ;
433+ it ( 'should support arbitrary custom function types' , function ( ) {
434+ var options , result ;
435+ options = {
436+ custom_function : { function_type : 'amazing' , source : 'awesome' }
437+ } ;
438+ result = cloudinary . utils . url ( "test" , options ) ;
439+ expect ( options ) . to . eql ( { } ) ;
440+ expect ( result ) . to . eql ( "http://res.cloudinary.com/test123/image/upload/fn_amazing:awesome/test" ) ;
441+ } ) ;
442+ it ( 'should support custom function with no source' , function ( ) {
443+ var options , result ;
444+ options = {
445+ custom_function : { function_type : 'wasm' }
446+ } ;
447+ result = cloudinary . utils . url ( "test" , options ) ;
448+ expect ( options ) . to . eql ( { } ) ;
449+ expect ( result ) . to . eql ( "http://res.cloudinary.com/test123/image/upload/fn_wasm:/test" ) ;
450+ } ) ;
451+ it ( 'should support custom function with no function_type' , function ( ) {
452+ var options , result ;
453+ options = {
454+ custom_function : { source : 'blur.wasm' }
455+ } ;
456+ result = cloudinary . utils . url ( "test" , options ) ;
457+ expect ( options ) . to . eql ( { } ) ;
458+ expect ( result ) . to . eql ( "http://res.cloudinary.com/test123/image/upload/fn_:blur.wasm/test" ) ;
459+ } ) ;
460+ it ( 'should support custom function that is not an object' , function ( ) {
461+ var options , result ;
462+ options = {
463+ custom_function : [ ]
464+ } ;
465+ result = cloudinary . utils . url ( "test" , options ) ;
466+ expect ( options ) . to . eql ( { } ) ;
467+ expect ( result ) . to . eql ( "http://res.cloudinary.com/test123/image/upload/fn_:/test" ) ;
468+ } ) ;
469+ it ( 'should support custom function with no function_type or source' , function ( ) {
470+ var options , result ;
471+ options = {
472+ custom_function : { }
473+ } ;
474+ result = cloudinary . utils . url ( "test" , options ) ;
475+ expect ( options ) . to . eql ( { } ) ;
476+ expect ( result ) . to . eql ( "http://res.cloudinary.com/test123/image/upload/fn_:/test" ) ;
477+ } ) ;
478+ it ( 'should support custom function of type remote' , function ( ) {
479+ var options , result ;
480+ options = {
481+ custom_function : { function_type : 'remote' , source : 'https://df34ra4a.execute-api.us-west-2.amazonaws.com/default/cloudinaryFunction' }
482+ } ;
483+ result = cloudinary . utils . url ( "test" , options ) ;
484+ expect ( options ) . to . eql ( { } ) ;
485+ expect ( result ) . to . eql ( "http://res.cloudinary.com/test123/image/upload/fn_remote:aHR0cHM6Ly9kZjM0cmE0YS5leGVjdXRlLWFwaS51cy13ZXN0LTIuYW1hem9uYXdzLmNvbS9kZWZhdWx0L2Nsb3VkaW5hcnlGdW5jdGlvbg==/test" ) ;
486+ } ) ;
487+ it ( 'should should not include custom function with undefined value' , function ( ) {
488+ var options , result ;
489+ options = {
490+ custom_function : undefined
491+ } ;
492+ result = cloudinary . utils . url ( "test" , options ) ;
493+ expect ( options ) . to . eql ( { } ) ;
494+ expect ( result ) . to . eql ( "http://res.cloudinary.com/test123/image/upload/test" ) ;
495+ } ) ;
424496 it ( "should support density" , function ( ) {
425497 var options , result ;
426498 options = {
0 commit comments