@@ -3,7 +3,7 @@ const sinon = require("sinon");
33// const requestUtils = require('../src/utils/request.js');
44const fs = require ( 'fs' ) ;
55const path = require ( 'path' ) ;
6-
6+ const pkg = require ( "../package.json" ) ;
77global . FormData = require ( 'formdata-node' ) ;
88
99const expect = chai . expect ;
@@ -48,12 +48,8 @@ describe("Testing SDK", function () {
4848 "width" : "400"
4949 } ]
5050 } ) ;
51-
52- expect ( url ) . to . match ( / ^ h t t p s \: \/ \/ i k \. i m a g e k i t \. i o \/ t e s t \_ u r l \_ e n d p o i n t \/ [ ^ \/ ] / ) ;
53- expect ( url ) . to . match ( new RegExp ( "[^\/]\/tr:" ) ) ;
54- expect ( url ) . to . match ( new RegExp ( ":h-300,w-400" ) ) ;
55- expect ( url ) . to . match ( / [ ^ \/ ] \/ t e s t _ p a t h \. j p g [ ^ \/ ] [ \? ] ? / ) ;
56- expect ( url ) . to . match ( / i k \- s d k \- v e r s i o n \= j a v a s c r i p t \- \d \. \d \. \d / ) ;
51+
52+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/tr:h-300,w-400/test_path.jpg?ik-sdk-version=javascript-${ pkg . version } ` ) ;
5753 } ) ;
5854
5955 it ( 'should generate the correct url with path param with multiple leading slash' , function ( ) {
@@ -64,11 +60,8 @@ describe("Testing SDK", function () {
6460 "width" : "400"
6561 } ]
6662 } )
67- expect ( url ) . to . match ( / ^ h t t p s \: \/ \/ i k \. i m a g e k i t \. i o \/ t e s t \_ u r l \_ e n d p o i n t \/ [ ^ \/ ] / ) ;
68- expect ( url ) . to . match ( new RegExp ( "[^\/]\/tr:" ) ) ;
69- expect ( url ) . to . match ( new RegExp ( ":h-300,w-400" ) ) ;
70- expect ( url ) . to . match ( / [ ^ \/ ] \/ t e s t _ p a t h \. j p g [ ^ \/ ] [ \? ] ? / ) ;
71- expect ( url ) . to . match ( / i k \- s d k \- v e r s i o n \= j a v a s c r i p t \- \d \. \d \. \d / ) ;
63+
64+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/tr:h-300,w-400/test_path.jpg?ik-sdk-version=javascript-${ pkg . version } ` ) ;
7265
7366 } ) ;
7467
@@ -81,11 +74,8 @@ describe("Testing SDK", function () {
8174 "width" : "400"
8275 } ]
8376 } )
84- expect ( url ) . to . match ( / ^ h t t p s \: \/ \/ i k \. i m a g e k i t \. i o \/ t e s t \_ u r l \_ e n d p o i n t \_ a l t \/ [ ^ \/ ] / ) ;
85- expect ( url ) . to . match ( new RegExp ( "[^\/]\/tr:" ) ) ;
86- expect ( url ) . to . match ( new RegExp ( ":h-300,w-400" ) ) ;
87- expect ( url ) . to . match ( / [ ^ \/ ] \/ t e s t _ p a t h \. j p g [ ^ \/ ] [ \? ] ? / ) ;
88- expect ( url ) . to . match ( / i k \- s d k \- v e r s i o n \= j a v a s c r i p t \- \d \. \d \. \d / ) ;
77+
78+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint_alt/tr:h-300,w-400/test_path.jpg?ik-sdk-version=javascript-${ pkg . version } ` ) ;
8979
9080 } ) ;
9181
@@ -98,9 +88,8 @@ describe("Testing SDK", function () {
9888 "width" : "400"
9989 } ]
10090 } ) ;
101- expect ( url ) . to . match ( / ^ h t t p s \: \/ \/ i k \. i m a g e k i t \. i o \/ t e s t \_ u r l \_ e n d p o i n t \/ t e s t \_ p a t h \. j p g \? / ) ;
102- expect ( url ) . to . match ( new RegExp ( '&tr=h-300%2Cw-400' ) ) ;
103- expect ( url ) . to . match ( / i k \- s d k \- v e r s i o n \= j a v a s c r i p t \- \d \. \d \. \d / ) ;
91+
92+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/test_path.jpg?ik-sdk-version=javascript-${ pkg . version } &tr=h-300%2Cw-400` ) ;
10493 } ) ;
10594
10695 it ( 'should generate the correct url with src param' , function ( ) {
@@ -111,9 +100,8 @@ describe("Testing SDK", function () {
111100 "width" : "400"
112101 } ]
113102 } ) ;
114- expect ( url ) . to . match ( / ^ h t t p s \: \/ \/ i k \. i m a g e k i t \. i o \/ t e s t \_ u r l \_ e n d p o i n t \/ t e s t \_ p a t h \_ a l t \. j p g [ ^ \/ ] / ) ;
115- expect ( url ) . to . match ( new RegExp ( '&tr=h-300%2Cw-400' ) ) ;
116- expect ( url ) . to . match ( / i k \- s d k \- v e r s i o n \= j a v a s c r i p t \- \d \. \d \. \d / ) ;
103+
104+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?ik-sdk-version=javascript-${ pkg . version } &tr=h-300%2Cw-400` ) ;
117105 } ) ;
118106
119107 it ( 'should generate the correct url with transformationPostion as query' , function ( ) {
@@ -125,9 +113,8 @@ describe("Testing SDK", function () {
125113 "width" : "400"
126114 } ]
127115 } ) ;
128- expect ( url ) . to . match ( / ^ h t t p s \: \/ \/ i k \. i m a g e k i t \. i o \/ t e s t \_ u r l \_ e n d p o i n t \/ t e s t \_ p a t h \_ a l t \. j p g \? / ) ;
129- expect ( url ) . to . match ( new RegExp ( '&tr=h-300%2Cw-400' ) ) ;
130- expect ( url ) . to . match ( / i k \- s d k \- v e r s i o n \= j a v a s c r i p t \- \d \. \d \. \d / ) ;
116+
117+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?ik-sdk-version=javascript-${ pkg . version } &tr=h-300%2Cw-400` ) ;
131118 } ) ;
132119
133120 it ( 'should generate the correct url with query params properly merged' , function ( ) {
@@ -140,11 +127,7 @@ describe("Testing SDK", function () {
140127 } ]
141128 } ) ;
142129
143- expect ( url ) . to . match ( / ^ h t t p s \: \/ \/ i k \. i m a g e k i t \. i o \/ t e s t \_ u r l \_ e n d p o i n t \/ t e s t \_ p a t h \_ a l t \. j p g \? t 1 = v 1 \& / ) ;
144- expect ( url ) . to . match ( new RegExp ( '&t2=v2&' ) ) ;
145- expect ( url ) . to . match ( new RegExp ( '&t3=v3&' ) ) ;
146- expect ( url ) . to . match ( new RegExp ( '&tr=h-300%2Cw-400' ) ) ;
147- expect ( url ) . to . match ( / i k \- s d k \- v e r s i o n \= j a v a s c r i p t \- \d \. \d \. \d / ) ;
130+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?t1=v1&ik-sdk-version=javascript-${ pkg . version } &t2=v2&t3=v3&tr=h-300%2Cw-400` ) ;
148131 } ) ;
149132
150133
@@ -159,12 +142,7 @@ describe("Testing SDK", function () {
159142 } ]
160143 } )
161144
162- expect ( url ) . to . match ( / ^ h t t p s \: \/ \/ i k \. i m a g e k i t \. i o \/ t e s t \_ u r l \_ e n d p o i n t \/ [ ^ \/ ] / ) ;
163- expect ( url ) . to . match ( new RegExp ( "[^\/]\/tr:" ) ) ;
164- expect ( url ) . to . match ( new RegExp ( ":h-300,w-400:rt-90" ) ) ;
165- expect ( url ) . to . not . match ( new RegExp ( ":rt-90:h-300,w-400" ) ) ;
166- expect ( url ) . to . match ( / [ ^ \/ ] \/ t e s t _ p a t h \. j p g [ ^ \/ ] [ \? ] ? / ) ;
167- expect ( url ) . to . match ( / i k \- s d k \- v e r s i o n \= j a v a s c r i p t \- \d \. \d \. \d / ) ;
145+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/tr:h-300,w-400:rt-90/test_path.jpg?ik-sdk-version=javascript-${ pkg . version } ` ) ;
168146 } ) ;
169147
170148
@@ -179,12 +157,7 @@ describe("Testing SDK", function () {
179157 } ]
180158 } )
181159
182- expect ( url ) . to . match ( / ^ h t t p s \: \/ \/ i k \. i m a g e k i t \. i o \/ t e s t \_ u r l \_ e n d p o i n t \/ [ ^ \/ ] / ) ;
183- expect ( url ) . to . match ( new RegExp ( "[^\/]\/tr:" ) ) ;
184- expect ( url ) . to . match ( new RegExp ( ":h-300,w-400:rndm_trnsf-abcd" ) ) ;
185- expect ( url ) . to . not . match ( new RegExp ( ":rndm_trnsf-abcd:h-300,w-400" ) ) ;
186- expect ( url ) . to . match ( / [ ^ \/ ] \/ t e s t _ p a t h \. j p g [ ^ \/ ] [ \? ] ? / ) ;
187- expect ( url ) . to . match ( / i k \- s d k \- v e r s i o n \= j a v a s c r i p t \- \d \. \d \. \d / ) ;
160+ expect ( url ) . equal ( `https://ik.imagekit.io/test_url_endpoint/tr:h-300,w-400:rndm_trnsf-abcd/test_path.jpg?ik-sdk-version=javascript-${ pkg . version } ` ) ;
188161 } ) ;
189162
190163 } ) ;
0 commit comments