Skip to content

Commit 3083284

Browse files
committed
test: add unit tests for helper methods in Helper class
1 parent f736fef commit 3083284

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "../test_helper"
4+
5+
class HelperTest < Minitest::Test
6+
def setup
7+
@client = Imagekit::Client.new(
8+
private_key: "test_private_key",
9+
password: "test_password"
10+
)
11+
@helper = Imagekit::Helpers::Helper.new(client: @client)
12+
end
13+
14+
def test_build_url
15+
result = @helper.build_url([])
16+
assert_instance_of(String, result)
17+
assert_equal("https://ik.imagekit.io/your_imagekit_id/sample-image.jpg?tr=w-400,h-300", result)
18+
end
19+
20+
def test_build_transformation_string
21+
result = @helper.build_transformation_string([])
22+
assert_instance_of(String, result)
23+
assert_equal("w-400,h-300", result)
24+
end
25+
26+
def test_get_authentication_parameters
27+
result = @helper.get_authentication_parameters("test_token", 1800)
28+
assert_instance_of(Hash, result)
29+
assert_equal("test_token", result[:token])
30+
assert_equal(1800, result[:expire])
31+
assert_equal("dummy_signature", result[:signature])
32+
end
33+
end

0 commit comments

Comments
 (0)