Skip to content

Commit 13b3d44

Browse files
author
Nir Maoz
authored
Add relevant overlay tests from cloudinary-core (#327)
* Add relevant overlay tests from cloudinary-core (as skipped)
1 parent ef83e96 commit 13b3d44

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

__TESTS__/unit/actions/Overlay.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,46 @@ describe('Tests for overlay actions', () => {
218218
// Explicitly check the resulting base64 string
219219
expect(asset.toString()).toContain(`l_fetch:aHR0cHM6Ly9yZXMuY2xvdWRpbmFyeS5jb20vZGVtby9pbWFnZS91cGxvYWQvY2k=.png/${sampleTxResizePad().toString()}`);
220220
});
221+
222+
it.skip("should serialize a text source", () => {
223+
const asset = createNewImage();
224+
const text = 'Cloudinary for the win!';
225+
const textStyle = sampleTextStyle();
226+
const textSource = Source.text(text, textStyle);
227+
asset.overlay(Overlay.source(textSource));
228+
229+
expect(asset.toString()).toBe("l_text:arial_50_bold_italic_strikethrough_justify_stroke_letter_spacing_10_line_spacing_20_letter_spacing_good_hinting_full:Cloudinary%20for%20the%20win%21'/fl_layer_apply");
230+
});
231+
232+
it("should serialize a fetch source", () => {
233+
const asset = createNewVideo();
234+
const REMOTE_URL = 'http://res.cloudinary.com/demo/sample.jpg';
235+
const expected = 'l_fetch:aHR0cDovL3Jlcy5jbG91ZGluYXJ5LmNvbS9kZW1vL3NhbXBsZS5qcGc=/fl_layer_apply';
236+
const actual = asset.overlay(Overlay.source(Source.fetch(REMOTE_URL))).toString();
237+
238+
expect(actual).toBe(expected);
239+
});
240+
241+
it.skip("should serialize a unicode url of fetch source", () => {
242+
const asset = createNewVideo();
243+
const REMOTE_URL = "https://upload.wikimedia.org/wikipedia/commons/2/2b/고창갯벌.jpg";
244+
const expected = "l_fetch:aHR0cHM6Ly91cGxvYWQud2lraW1lZGlhLm9yZy93aWtpcGVkaWEvY29tbW9ucy8yLzJiLyVFQSVCMyVBMCVFQyVCMCVCRCVFQSVCMCVBRiVFQiVCMiU4Qy5qcGc=/fl_layer_apply";
245+
const actual = asset.overlay(Overlay.source(Source.fetch(REMOTE_URL))).toString();
246+
247+
expect(actual).toBe(expected);
248+
});
249+
250+
it.skip("should support string interpolation", () => {
251+
const asset = createNewImage();
252+
const text = "$(start)Hello $(name)$(ext), $(no ) $( no)$(end)";
253+
const textStyle = sampleTextStyle();
254+
const textSource = Source.text(text, textStyle);
255+
asset.overlay(Overlay.source(textSource));
256+
257+
expect(asset.toString()).toBe("l_text:arial_50_bold_italic_strikethrough_justify_stroke_letter_spacing_10_line_spacing_20_letter_spacing_good_hinting_full:$(start)Hello%20$(name)$(ext)%252C%20%24%28no%20%29%20%24%28%20no%29$(end)/fl_layer_apply");
258+
});
259+
260+
it.skip("should throw an exception if fontFamily is not provided", () => {
261+
expect(() => new TextStyle(null, 17)).toThrow();
262+
});
221263
});

0 commit comments

Comments
 (0)