Skip to content

Commit 188eeee

Browse files
committed
feat(tests): add tests for transformation handling with absolute URLs and non-default endpoints
1 parent 96c640d commit 188eeee

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/url-generation/basic.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,39 @@ describe('URL generation', function () {
117117
expect(url).toBe(`https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=h-300,w-400`);
118118
});
119119

120+
it('should add transformation as query when src has absolute url even if transformationPosition is path', function () {
121+
const url = client.helper.buildSrc({
122+
urlEndpoint: 'https://ik.imagekit.io/test_url_endpoint',
123+
transformationPosition: 'path',
124+
src: 'https://my.custom.domain.com/test_path.jpg',
125+
transformation: [
126+
{
127+
height: '300',
128+
width: '400',
129+
},
130+
],
131+
});
132+
133+
// Now transformed URL goes into query since transformationPosition is "query".
134+
expect(url).toBe(`https://my.custom.domain.com/test_path.jpg?tr=h-300,w-400`);
135+
});
136+
137+
it('Handle non-default url-endpoint case', function () {
138+
const url = client.helper.buildSrc({
139+
urlEndpoint: 'https://ik.imagekit.io/imagekit_id/new-endpoint/',
140+
src: '/test_path.jpg',
141+
transformation: [
142+
{
143+
height: '300',
144+
width: '400',
145+
},
146+
],
147+
});
148+
149+
// Now transformed URL goes into query since transformationPosition is "query".
150+
expect(url).toBe(`https://ik.imagekit.io/imagekit_id/new-endpoint/test_path.jpg?tr=h-300,w-400`);
151+
});
152+
120153
it('should generate the correct URL when the provided path contains multiple leading slashes', function () {
121154
const url = client.helper.buildSrc({
122155
urlEndpoint: 'https://ik.imagekit.io/test_url_endpoint',

0 commit comments

Comments
 (0)