@@ -49,7 +49,7 @@ describe("URL generation", function () {
4949 } ) ;
5050
5151 it ( 'should generate the url without sdk-version' , function ( ) {
52- const ik = new ImageKit ( { ...initializationParams , sdkVersion : "" } )
52+ const ik = new ImageKit ( { ...initializationParams , sdkVersion : "" } )
5353
5454 const url = ik . url ( {
5555 path : "/test_path.jpg" ,
@@ -231,7 +231,7 @@ describe("URL generation", function () {
231231
232232 expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/tr:-/test_path.jpg` ) ;
233233 } ) ;
234-
234+
235235 /**
236236 * Provided to provide support to a new transform without sdk update
237237 */
@@ -281,6 +281,99 @@ describe("URL generation", function () {
281281 expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/tr:di-test_path.jpg/test_path1.jpg` ) ;
282282 } ) ;
283283
284+ it ( 'skip transformation if it is false' , function ( ) {
285+ const url = imagekit . url ( {
286+ path : "/test_path1.jpg" ,
287+ transformation : [ {
288+ defaultImage : "/test_path.jpg" ,
289+ effectContrast : false
290+ } ]
291+ } )
292+
293+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/tr:di-test_path.jpg/test_path1.jpg` ) ;
294+ } ) ;
295+
296+ it ( 'include just key if value is empty string' , function ( ) {
297+ const url = imagekit . url ( {
298+ path : "/test_path1.jpg" ,
299+ transformation : [ {
300+ defaultImage : "/test_path.jpg" ,
301+ shadow : ""
302+ } ]
303+ } )
304+
305+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/tr:di-test_path.jpg,e-shadow/test_path1.jpg` ) ;
306+ } ) ;
307+
308+ it ( 'include value if set' , function ( ) {
309+ const url = imagekit . url ( {
310+ path : "/test_path1.jpg" ,
311+ transformation : [ {
312+ defaultImage : "/test_path.jpg" ,
313+ shadow : "bl-15_st-40_x-10_y-N5"
314+ } ]
315+ } )
316+
317+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/tr:di-test_path.jpg,e-shadow-bl-15_st-40_x-10_y-N5/test_path1.jpg` ) ;
318+ } ) ;
319+
320+ it ( 'trim with true as boolean' , function ( ) {
321+ const url = imagekit . url ( {
322+ path : "/test_path1.jpg" ,
323+ transformation : [ {
324+ defaultImage : "/test_path.jpg" ,
325+ trim : true
326+ } ]
327+ } )
328+
329+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/tr:di-test_path.jpg,t-true/test_path1.jpg` ) ;
330+ } ) ;
331+
332+ it ( 'trim with true as string' , function ( ) {
333+ const url = imagekit . url ( {
334+ path : "/test_path1.jpg" ,
335+ transformation : [ {
336+ defaultImage : "/test_path.jpg" ,
337+ trim : "true"
338+ } ]
339+ } )
340+
341+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/tr:di-test_path.jpg,t-true/test_path1.jpg` ) ;
342+ } ) ;
343+
344+ it ( 'ai remove background' , function ( ) {
345+ const url = imagekit . url ( {
346+ path : "/test_path1.jpg" ,
347+ transformation : [ {
348+ aiRemoveBackground : true
349+ } ]
350+ } )
351+
352+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/tr:e-bgremove/test_path1.jpg` ) ;
353+ } ) ;
354+
355+ it ( 'ai remove background true as string' , function ( ) {
356+ const url = imagekit . url ( {
357+ path : "/test_path1.jpg" ,
358+ transformation : [ {
359+ aiRemoveBackground : "true"
360+ } ]
361+ } )
362+
363+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/tr:e-bgremove/test_path1.jpg` ) ;
364+ } ) ;
365+
366+ it ( 'ai remove background other than true' , function ( ) {
367+ const url = imagekit . url ( {
368+ path : "/test_path1.jpg" ,
369+ transformation : [ {
370+ aiRemoveBackground : "false"
371+ } ]
372+ } )
373+
374+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/test_path1.jpg` ) ;
375+ } ) ;
376+
284377 it ( 'All combined' , function ( ) {
285378 const url = imagekit . url ( {
286379 path : "/test_path.jpg" ,
0 commit comments