Skip to content

Commit 93f86d3

Browse files
committed
added test
1 parent f636130 commit 93f86d3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/imagekit/url_test.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,16 @@
259259
expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/default-image.jpg?ik-sdk-version=ruby-#{ImageKitIo::Sdk::VERSION}&γειασας=γειασας")
260260
end
261261

262+
it 'test_generate_url_with_absolute_path' do
263+
options = { path: "https://example.com/external-image.jpg",
264+
query_parameters: { "γειασας": "γειασας" },
265+
transformation: [{ height: 300, width: 400 }]
266+
}
267+
url = url_obj.generate_url(options)
268+
269+
expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/https%3A%2F%2Fexample.com%2Fexternal-image.jpg?ik-sdk-version=ruby-#{ImageKitIo::Sdk::VERSION}&γειασας=γειασας")
270+
end
271+
262272
it "test_generate_url_with_src_checking_query_param_added" do
263273

264274
options = { src: "https://ik.imagekit.io/ldt7znpgpjs/test_YhNhoRxWt.jpg?another=abc&xyz=888",
@@ -360,6 +370,19 @@
360370
expect(url).to include("https://ik.imagekit.io/your_imagekit_id/endpoint/tr:h-300,w-400/Fjällräven_KnSJwp87u6q.png?ik-sdk-version=ruby-#{ImageKitIo::Sdk::VERSION}&ik-s=")
361371
end
362372

373+
it 'test_generate_url_with_absolute_path_and_signed' do
374+
allow(url_obj).to receive(:get_signature_timestamp).with(5) { 100 }
375+
options = { path: "https://example.com/external-image.jpg",
376+
query_parameters: { "γειασας": "γειασας" },
377+
transformation: [{ height: 300, width: 400 }],
378+
signed: true,
379+
expire_seconds: 5
380+
}
381+
url = url_obj.generate_url(options)
382+
383+
expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/https%3A%2F%2Fexample.com%2Fexternal-image.jpg?ik-sdk-version=ruby-#{ImageKitIo::Sdk::VERSION}&γειασας=γειασας&ik-s=1ce525443b5ea4f1e66e8e89d585a8c95ae043c2&ik-t=100")
384+
end
385+
363386
it "test_url_with_invalid_args_returns_as_it_is" do
364387

365388
options = { path: "/default-image.jpg",

0 commit comments

Comments
 (0)