11const cloudinary = require ( "../../cloudinary" ) ;
22const createTestConfig = require ( '../testUtils/createTestConfig' ) ;
33const helper = require ( "../spechelper" ) ;
4- const { SIMPLE_PARAMS } = require ( `../../${ helper . libPath } /utils/consts` ) ;
4+ const { SIMPLE_PARAMS } = require ( `../../${ helper . libPath } /utils/consts` ) ;
5+ const { generate_transformation_string} = require ( "../../lib/utils" ) ;
56
67describe ( "normalize_expression tests" , function ( ) {
78 beforeEach ( function ( ) {
@@ -12,7 +13,21 @@ describe("normalize_expression tests", function () {
1213 } ) ) ;
1314 } ) ;
1415
15- it ( "Expression normalization" , function ( ) {
16+ it ( 'should normalize start_offset' , function ( ) {
17+ const result = generate_transformation_string ( {
18+ "start_offset" : "idu - 5"
19+ } ) ;
20+ expect ( result ) . to . equal ( "so_idu_sub_5" ) ;
21+ } ) ;
22+
23+ it ( 'should normalize end_offset' , function ( ) {
24+ const result = generate_transformation_string ( {
25+ "end_offset" : "idu - 5"
26+ } ) ;
27+ expect ( result ) . to . equal ( "eo_idu_sub_5" ) ;
28+ } ) ;
29+
30+ it ( "Expression normalization" , function ( ) {
1631 const cases = {
1732 'null is not affected' : [ null , null ] ,
1833 'None is not affected' : [ 'None' , 'None' ] ,
@@ -61,8 +76,8 @@ describe("normalize_expression tests", function () {
6176 const value = "width * 2" ;
6277 const normalizedValue = "w_mul_2" ;
6378 const normalizedParams = [ "angle" , "aspect_ratio" , "dpr" , "effect" , "height" , "opacity" , "quality" , "radius" ,
64- "width" , "x" , "y" , "zoom" ] ;
65- const nonNormalizedParams = simpleTransformationParams . concat ( 'overlay' , 'underlay' )
79+ "width" , "x" , "y" , "zoom" , "end_offset" , "start_offset" ] ;
80+ const nonNormalizedParams = simpleTransformationParams . concat ( 'overlay' , 'underlay' ) . filter ( param => ! normalizedParams . includes ( param ) ) ;
6681 normalizedParams . forEach ( ( param ) => {
6782 it ( `should normalize value in ${ param } ` , ( ) => {
6883 // c_scale needed to test h_ and w_ parameters that are ignored without crop mode
0 commit comments