@@ -2,6 +2,13 @@ import {createNewImage} from "../../TestUtils/createCloudinaryImage";
2
2
import { Resize } from "../../../src/actions/resize" ;
3
3
import { Rotate } from "../../../src/actions/rotate" ;
4
4
import { SEO_TYPES } from "../../../src/assets/CloudinaryFile" ;
5
+ import {
6
+ generateTransformationString
7
+ } from "@cloudinary/transformation-builder-sdk/backwards/generateTransformationString" ;
8
+ import { Effect } from "@cloudinary/transformation-builder-sdk/actions/effect" ;
9
+ import { Border } from "@cloudinary/transformation-builder-sdk/actions" ;
10
+ import { RoundCorners } from "../../../src/actions/roundCorners" ;
11
+ import { transformationStringFromObject } from "../../../src" ;
5
12
6
13
7
14
describe ( 'Tests for URL configuration' , ( ) => {
@@ -129,4 +136,31 @@ describe('Tests for URL configuration', () => {
129
136
expect ( url ) . toEqual ( `https://res.cloudinary.com/demo/image/upload/sample?_i=abcde&_z=1234&_t=false&_a=DATAABAQZAA0` ) ;
130
137
} ) ;
131
138
139
+ it ( 'Should include transformation string' , function ( ) {
140
+ const image = createNewImage ( 'sample' , { cloudName : 'demo' } , { analytics : false } ) ;
141
+ const transformation = transformationStringFromObject ( { width : 100 } ) ;
142
+ const url = image . addTransformation ( transformation ) . toURL ( ) ;
143
+ expect ( url ) . toEqual ( "https://res.cloudinary.com/demo/image/upload/w_100/sample" ) ;
144
+ } ) ;
145
+
146
+ it ( 'Should include transformation string created from an array of nested transformations' , function ( ) {
147
+ const image = createNewImage ( 'sample' , { cloudName : 'demo' } , { analytics : false } ) ;
148
+ const transformation = transformationStringFromObject ( { transformation : [ { width : 100 } , { height : 100 } ] } ) ;
149
+ const url = image . addTransformation ( transformation ) . toURL ( ) ;
150
+ expect ( url ) . toEqual ( "https://res.cloudinary.com/demo/image/upload/w_100/h_100/sample" ) ;
151
+ } ) ;
152
+
153
+ it ( 'Should include transformation string created from an array of transformations' , function ( ) {
154
+ const image = createNewImage ( 'sample' , { cloudName : 'demo' } , { analytics : false } ) ;
155
+ const transformation = transformationStringFromObject ( [ { width : 100 } , { height : 100 } ] ) ;
156
+ const url = image . addTransformation ( transformation ) . toURL ( ) ;
157
+ expect ( url ) . toEqual ( "https://res.cloudinary.com/demo/image/upload/w_100/h_100/sample" ) ;
158
+ } ) ;
159
+
160
+ it ( 'Should include both transformation string and transformation action' , function ( ) {
161
+ const image = createNewImage ( 'sample' , { cloudName : 'demo' } , { analytics : false } ) ;
162
+ const transformation = transformationStringFromObject ( { transformation : [ { width : 100 } , { height : 100 } ] } ) ;
163
+ const url = image . effect ( Effect . sepia ( 10 ) ) . addTransformation ( transformation ) . border ( Border . roundCorners ( RoundCorners . byRadius ( 50 ) ) ) . toURL ( ) ;
164
+ expect ( url ) . toEqual ( "https://res.cloudinary.com/demo/image/upload/e_sepia:10/w_100/h_100/bo_0px_solid_transparent,r_50/sample" ) ;
165
+ } ) ;
132
166
} ) ;
0 commit comments