@@ -29,7 +29,8 @@ const PUBLIC_ID_3 = PUBLIC_ID + "_3";
2929const PUBLIC_ID_4 = PUBLIC_ID + "_4" ;
3030const PUBLIC_ID_5 = PUBLIC_ID + "_5" ;
3131const PUBLIC_ID_6 = PUBLIC_ID + "_6" ;
32- const NAMED_TRANSFORMATION = "npm_api_test_transformation" + SUFFIX ;
32+ const NAMED_TRANSFORMATION = "npm_api_test_transformation_" + SUFFIX ;
33+ const NAMED_TRANSFORMATION2 = "npm_api_test_transformation_2_" + SUFFIX ;
3334const API_TEST_UPLOAD_PRESET1 = "npm_api_test_upload_preset_1_" + SUFFIX ;
3435const API_TEST_UPLOAD_PRESET2 = "npm_api_test_upload_preset_2_" + SUFFIX ;
3536const API_TEST_UPLOAD_PRESET3 = "npm_api_test_upload_preset_3_" + SUFFIX ;
@@ -469,7 +470,13 @@ describe("api", function() {
469470 itBehavesLike ( "a list with a cursor" , cloudinary . v2 . api . transformations ) ;
470471 transformationName = "api_test_transformation3" + SUFFIX ;
471472 after ( function ( ) {
472- return Q . allSettled ( [ cloudinary . v2 . api . delete_transformation ( transformationName ) , cloudinary . v2 . api . delete_transformation ( NAMED_TRANSFORMATION ) ] ) . finally ( function ( ) { } ) ;
473+ return Q . allSettled (
474+ [
475+ cloudinary . v2 . api . delete_transformation ( transformationName ) ,
476+ cloudinary . v2 . api . delete_transformation ( NAMED_TRANSFORMATION ) ,
477+ cloudinary . v2 . api . delete_transformation ( NAMED_TRANSFORMATION2 )
478+ ]
479+ ) . finally ( function ( ) { } ) ;
473480 } ) ;
474481 it ( "should allow listing transformations" , function ( ) {
475482 this . timeout ( helper . TIMEOUT_MEDIUM ) ;
@@ -509,62 +516,84 @@ describe("api", function() {
509516 expect ( transformation . allowed_for_strict ) . not . to . be . ok ( ) ;
510517 } ) ;
511518 } ) ;
512- it ( "should allow creating named transformation" , function ( ) {
513- this . timeout ( helper . TIMEOUT_MEDIUM ) ;
514- return cloudinary . v2 . api . create_transformation ( NAMED_TRANSFORMATION , {
515- crop : "scale" ,
516- width : 102
517- } ) . then ( ( ) => cloudinary . v2 . api . transformation ( NAMED_TRANSFORMATION )
518- ) . then ( function ( transformation ) {
519- expect ( transformation ) . not . to . eql ( void 0 ) ;
520- expect ( transformation . allowed_for_strict ) . to . be . ok ( ) ;
521- expect ( transformation . info ) . to . eql ( [
522- {
523- crop : "scale" ,
524- width : 102
525- }
526- ] ) ;
527- expect ( transformation . used ) . not . to . be . ok ( ) ;
519+ describe ( "Named Transformations" , function ( ) {
520+ it ( "should allow creating named transformation" , function ( ) {
521+ this . timeout ( helper . TIMEOUT_MEDIUM ) ;
522+ return cloudinary . v2 . api . create_transformation ( NAMED_TRANSFORMATION , {
523+ crop : "scale" ,
524+ width : 102
525+ } ) . then ( ( ) => cloudinary . v2 . api . transformation ( NAMED_TRANSFORMATION )
526+ ) . then ( function ( transformation ) {
527+ expect ( transformation ) . not . to . eql ( void 0 ) ;
528+ expect ( transformation . allowed_for_strict ) . to . be . ok ( ) ;
529+ expect ( transformation . info ) . to . eql ( [
530+ {
531+ crop : "scale" ,
532+ width : 102
533+ }
534+ ] ) ;
535+ expect ( transformation . used ) . not . to . be . ok ( ) ;
536+ } ) ;
528537 } ) ;
529- } ) ;
530- it ( "should allow listing of named transformations" , function ( ) {
531- return helper . mockPromise ( function ( xhr , write , request ) {
532- cloudinary . v2 . api . transformations ( {
533- named : true
538+ it ( "should allow creating named transformation with an empty format" , function ( ) {
539+ this . timeout ( helper . TIMEOUT_MEDIUM ) ;
540+ return cloudinary . v2 . api . create_transformation ( NAMED_TRANSFORMATION2 , {
541+ crop : "scale" ,
542+ width : 102 ,
543+ format : ''
544+ } ) . then ( ( ) => cloudinary . v2 . api . transformation ( NAMED_TRANSFORMATION2 )
545+ ) . then ( function ( transformation ) {
546+ expect ( transformation ) . not . to . eql ( void 0 ) ;
547+ expect ( transformation . allowed_for_strict ) . to . be . ok ( ) ;
548+ expect ( transformation . info ) . to . eql ( [
549+ {
550+ crop : "scale" ,
551+ width : 102 ,
552+ extension : 'none'
553+ }
554+ ] ) ;
555+ expect ( transformation . used ) . not . to . be . ok ( ) ;
534556 } ) ;
535- return sinon . assert . calledWith ( request , sinon . match ( {
536- query : sinon . match ( 'named=true' )
537- } , "named=true" ) ) ;
538557 } ) ;
539- } ) ;
540- it ( "should allow unsafe update of named transformation" , function ( ) {
541- this . timeout ( helper . TIMEOUT_MEDIUM ) ;
542- return cloudinary . v2 . api . create_transformation ( transformationName , {
543- crop : "scale" ,
544- width : 102
545- } ) . then ( result => cloudinary . v2 . api . update_transformation ( transformationName , {
546- unsafe_update : {
558+ it ( "should allow listing of named transformations" , function ( ) {
559+ return helper . mockPromise ( function ( xhr , write , request ) {
560+ cloudinary . v2 . api . transformations ( {
561+ named : true
562+ } ) ;
563+ return sinon . assert . calledWith ( request , sinon . match ( {
564+ query : sinon . match ( 'named=true' )
565+ } , "named=true" ) ) ;
566+ } ) ;
567+ } ) ;
568+ it ( "should allow unsafe update of named transformation" , function ( ) {
569+ this . timeout ( helper . TIMEOUT_MEDIUM ) ;
570+ return cloudinary . v2 . api . create_transformation ( transformationName , {
547571 crop : "scale" ,
548- width : 103
549- }
550- } ) ) . then ( result => cloudinary . v2 . api . transformation ( transformationName )
551- ) . then ( transformation => {
552- expect ( transformation ) . not . to . eql ( void 0 ) ;
553- expect ( transformation . info ) . to . eql ( [
554- {
572+ width : 102
573+ } ) . then ( result => cloudinary . v2 . api . update_transformation ( transformationName , {
574+ unsafe_update : {
555575 crop : "scale" ,
556576 width : 103
557577 }
558- ] ) ;
559- expect ( transformation . used ) . not . to . be . ok ( ) ;
578+ } ) ) . then ( result => cloudinary . v2 . api . transformation ( transformationName )
579+ ) . then ( transformation => {
580+ expect ( transformation ) . not . to . eql ( void 0 ) ;
581+ expect ( transformation . info ) . to . eql ( [
582+ {
583+ crop : "scale" ,
584+ width : 103
585+ }
586+ ] ) ;
587+ expect ( transformation . used ) . not . to . be . ok ( ) ;
588+ } ) ;
589+ } ) ;
590+ it ( "should allow deleting named transformation" , function ( ) {
591+ this . timeout ( helper . TIMEOUT_MEDIUM ) ;
592+ return cloudinary . v2 . api . delete_transformation ( NAMED_TRANSFORMATION ) . then ( ( ) => {
593+ return cloudinary . v2 . api . transformation ( NAMED_TRANSFORMATION ) ;
594+ } ) . then ( ( ) => expect ( ) . fail ( )
595+ ) . catch ( ( { error} ) => expect ( error . http_code ) . to . eql ( 404 ) ) ;
560596 } ) ;
561- } ) ;
562- it ( "should allow deleting named transformation" , function ( ) {
563- this . timeout ( helper . TIMEOUT_MEDIUM ) ;
564- return cloudinary . v2 . api . delete_transformation ( NAMED_TRANSFORMATION ) . then ( ( ) => {
565- return cloudinary . v2 . api . transformation ( NAMED_TRANSFORMATION ) ;
566- } ) . then ( ( ) => expect ( ) . fail ( )
567- ) . catch ( ( { error} ) => expect ( error . http_code ) . to . eql ( 404 ) ) ;
568597 } ) ;
569598 it ( "should allow deleting implicit transformation" , function ( ) {
570599 this . timeout ( helper . TIMEOUT_MEDIUM ) ;
0 commit comments