Skip to content

Commit 9275a50

Browse files
committed
explict encoding test cases
1 parent 57e0066 commit 9275a50

File tree

1 file changed

+100
-2
lines changed

1 file changed

+100
-2
lines changed

test/url-generation/overlay.js

Lines changed: 100 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ describe("Overlay Transformation Test Cases", function () {
273273
});
274274

275275

276-
describe("Edge cases", function () {
276+
describe("Overlay encoding test cases", function () {
277277
const imagekit = new ImageKit({
278278
...initializationParams,
279279
urlEndpoint: "https://ik.imagekit.io/demo", // Using real url to test correctness quickly by clicking link
@@ -343,4 +343,102 @@ describe("Edge cases", function () {
343343
});
344344
expect(url).equal(`https://ik.imagekit.io/demo/tr:l-text,ie-TGV0J3MgdXNlIMKpLCDCriwg4oSiLCBldGM%3D,l-end/medium_cafe_B1iTdD0C.jpg`);
345345
});
346-
});
346+
347+
it('Text overlay with explicit plain encoding', function () {
348+
const url = imagekit.url({
349+
path: "/sample.jpg",
350+
transformation: [{
351+
overlay: {
352+
type: "text",
353+
text: "HelloWorld",
354+
encoding: "plain"
355+
}
356+
}]
357+
});
358+
expect(url).equal(`https://ik.imagekit.io/demo/tr:l-text,i-HelloWorld,l-end/sample.jpg`);
359+
});
360+
361+
it('Text overlay with explicit base64 encoding', function () {
362+
const url = imagekit.url({
363+
path: "/sample.jpg",
364+
transformation: [{
365+
overlay: {
366+
type: "text",
367+
text: "HelloWorld",
368+
encoding: "base64"
369+
}
370+
}]
371+
});
372+
expect(url).equal(`https://ik.imagekit.io/demo/tr:l-text,ie-${encodeURIComponent(safeBtoa("HelloWorld"))},l-end/sample.jpg`);
373+
});
374+
375+
it('Image overlay with explicit plain encoding', function () {
376+
const url = imagekit.url({
377+
path: "/sample.jpg",
378+
transformation: [{
379+
overlay: {
380+
type: "image",
381+
input: "/customer/logo.png",
382+
encoding: "plain"
383+
}
384+
}]
385+
});
386+
expect(url).equal(`https://ik.imagekit.io/demo/tr:l-image,i-customer@@logo.png,l-end/sample.jpg`);
387+
});
388+
389+
it('Image overlay with explicit base64 encoding', function () {
390+
const url = imagekit.url({
391+
path: "/sample.jpg",
392+
transformation: [{
393+
overlay: {
394+
type: "image",
395+
input: "/customer/logo.png",
396+
encoding: "base64"
397+
}
398+
}]
399+
});
400+
expect(url).equal(`https://ik.imagekit.io/demo/tr:l-image,ie-${encodeURIComponent(safeBtoa("customer/logo.png"))},l-end/sample.jpg`);
401+
});
402+
403+
it('Video overlay with explicit base64 encoding', function () {
404+
const url = imagekit.url({
405+
path: "/sample.mp4",
406+
transformation: [{
407+
overlay: {
408+
type: "video",
409+
input: "/path/to/video.mp4",
410+
encoding: "base64"
411+
}
412+
}]
413+
});
414+
expect(url).equal(`https://ik.imagekit.io/demo/tr:l-video,ie-${encodeURIComponent(safeBtoa("path/to/video.mp4"))},l-end/sample.mp4`);
415+
});
416+
417+
it('Subtitle overlay with explicit plain encoding', function () {
418+
const url = imagekit.url({
419+
path: "/sample.mp4",
420+
transformation: [{
421+
overlay: {
422+
type: "subtitle",
423+
input: "/sub.srt",
424+
encoding: "plain"
425+
}
426+
}]
427+
});
428+
expect(url).equal(`https://ik.imagekit.io/demo/tr:l-subtitle,i-sub.srt,l-end/sample.mp4`);
429+
});
430+
431+
it('Subtitle overlay with explicit base64 encoding', function () {
432+
const url = imagekit.url({
433+
path: "/sample.mp4",
434+
transformation: [{
435+
overlay: {
436+
type: "subtitle",
437+
input: "sub.srt",
438+
encoding: "base64"
439+
}
440+
}]
441+
});
442+
expect(url).equal(`https://ik.imagekit.io/demo/tr:l-subtitle,ie-${encodeURIComponent(safeBtoa("sub.srt"))},l-end/sample.mp4`);
443+
});
444+
});

0 commit comments

Comments
 (0)