Skip to content

Commit bfba059

Browse files
committed
test: enhance URL signing tests with detailed descriptions and additional cases for special characters
1 parent 2c4a6d2 commit bfba059

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Generate a simple URL without any transformations:
9898
import ImageKit from '@imagekit/nodejs';
9999

100100
const client = new ImageKit({
101-
privateKey: process.env['IMAGEKIT_PRIVATE_KEY']
101+
privateKey: process.env['IMAGEKIT_PRIVATE_KEY'],
102102
});
103103

104104
// Basic URL without transformations
@@ -300,11 +300,11 @@ try {
300300
// Verify and unwrap webhook payload
301301
const event = client.webhooks.unwrap(
302302
webhookBody, // Raw webhook payload (string)
303-
{
303+
{
304304
headers: webhookHeaders, // Request headers containing signature
305-
}
305+
},
306306
);
307-
307+
308308
console.log('Webhook signature is valid');
309309
console.log('Event type:', event.type);
310310
console.log('Event data:', event.data);

tests/custom-tests/url-generation/signing.test.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('URL Signing', function () {
4949
expect(url).toContain('ik-t');
5050
});
5151

52-
it('Special characters', function () {
52+
it('should generate signed URL with special characters in filename', function () {
5353
const url = client.helper.buildSrc({
5454
urlEndpoint: 'https://ik.imagekit.io/demo/',
5555
src: 'sdk-testing-files/हिन्दी.png',
@@ -61,7 +61,7 @@ describe('URL Signing', function () {
6161
);
6262
});
6363

64-
it('Text overlay with special characters', function () {
64+
it('should generate signed URL with text overlay containing special characters', function () {
6565
const url = client.helper.buildSrc({
6666
urlEndpoint: 'https://ik.imagekit.io/demo/',
6767
src: 'sdk-testing-files/हिन्दी.png',
@@ -88,6 +88,34 @@ describe('URL Signing', function () {
8888
);
8989
});
9090

91+
it('should generate signed URL with text overlay and special characters using path transformation position', function () {
92+
const url = client.helper.buildSrc({
93+
urlEndpoint: 'https://ik.imagekit.io/demo/',
94+
src: 'sdk-testing-files/हिन्दी.png',
95+
transformationPosition: 'path',
96+
transformation: [
97+
{
98+
overlay: {
99+
type: 'text',
100+
text: 'हिन्दी',
101+
transformation: [
102+
{
103+
fontColor: 'red',
104+
fontSize: '32',
105+
fontFamily: 'sdk-testing-files/Poppins-Regular_Q15GrYWmL.ttf',
106+
},
107+
],
108+
},
109+
},
110+
],
111+
signed: true,
112+
});
113+
114+
expect(url).toBe(
115+
'https://ik.imagekit.io/demo/tr:l-text,ie-4KS54KS%2F4KSo4KWN4KSm4KWA,co-red,fs-32,ff-sdk-testing-files@@Poppins-Regular_Q15GrYWmL.ttf,l-end/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?ik-s=69f2ecbb7364bbbad24616e1f7f1bac5a560fc71',
116+
);
117+
});
118+
91119
it('should generate signed URL with query parameters', function () {
92120
const url = client.helper.buildSrc({
93121
urlEndpoint: 'https://ik.imagekit.io/demo/',
@@ -132,7 +160,7 @@ describe('URL Signing', function () {
132160
expect(url).not.toContain('ik-t=');
133161
});
134162

135-
it('transformationPosition as path', function () {
163+
it('should generate signed URL with transformations in path position and query parameters', function () {
136164
const url = client.helper.buildSrc({
137165
urlEndpoint: 'https://ik.imagekit.io/demo/',
138166
src: 'sdk-testing-files/future-search.png',

0 commit comments

Comments
 (0)