11# frozen_string_literal: true
22
3- require_relative "../../ test_helper"
3+ require_relative "../test_helper"
44
55class ResponsiveImageAttributesTest < Minitest ::Test
66 def setup
@@ -20,10 +20,11 @@ def test_bare_minimum_input
2020 expected = {
2121 src : "https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max" ,
2222 src_set : "https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w" ,
23- sizes : "100vw"
23+ sizes : "100vw" ,
24+ width : nil
2425 }
2526
26- assert_equal ( expected , result )
27+ assert_equal ( expected , result . to_h )
2728 end
2829
2930 def test_sizes_provided_100vw
@@ -37,10 +38,11 @@ def test_sizes_provided_100vw
3738 expected = {
3839 src : "https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max" ,
3940 src_set : "https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w" ,
40- sizes : "100vw"
41+ sizes : "100vw" ,
42+ width : nil
4143 }
4244
43- assert_equal ( expected , result )
45+ assert_equal ( expected , result . to_h )
4446 end
4547
4648 def test_width_only_dpr_strategy
@@ -54,10 +56,11 @@ def test_width_only_dpr_strategy
5456 expected = {
5557 src : "https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max" ,
5658 src_set : "https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 1x, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 2x" ,
57- width : 400
59+ sizes : nil ,
60+ width : 400.0
5861 }
5962
60- assert_equal ( expected , result )
63+ assert_equal ( expected , result . to_h )
6164 end
6265
6366 def test_custom_breakpoints
@@ -72,10 +75,11 @@ def test_custom_breakpoints
7275 expected = {
7376 src : "https://ik.imagekit.io/demo/sample.jpg?tr=w-800,c-at_max" ,
7477 src_set : "https://ik.imagekit.io/demo/sample.jpg?tr=w-200,c-at_max 200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-400,c-at_max 400w, https://ik.imagekit.io/demo/sample.jpg?tr=w-800,c-at_max 800w" ,
75- sizes : "100vw"
78+ sizes : "100vw" ,
79+ width : nil
7680 }
7781
78- assert_equal ( expected , result )
82+ assert_equal ( expected , result . to_h )
7983 end
8084
8185 def test_preserves_caller_transformations
@@ -90,10 +94,11 @@ def test_preserves_caller_transformations
9094 expected = {
9195 src : "https://ik.imagekit.io/demo/sample.jpg?tr=h-300:w-1080,c-at_max" ,
9296 src_set : "https://ik.imagekit.io/demo/sample.jpg?tr=h-300:w-640,c-at_max 1x, https://ik.imagekit.io/demo/sample.jpg?tr=h-300:w-1080,c-at_max 2x" ,
93- width : 500
97+ sizes : nil ,
98+ width : 500.0
9499 }
95100
96- assert_equal ( expected , result )
101+ assert_equal ( expected , result . to_h )
97102 end
98103
99104 def test_both_sizes_and_width_passed
@@ -109,10 +114,10 @@ def test_both_sizes_and_width_passed
109114 src : "https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max" ,
110115 src_set : "https://ik.imagekit.io/demo/sample.jpg?tr=w-384,c-at_max 384w, https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w" ,
111116 sizes : "50vw" ,
112- width : 600
117+ width : 600.0
113118 }
114119
115- assert_equal ( expected , result )
120+ assert_equal ( expected , result . to_h )
116121 end
117122
118123 def test_multiple_transformations
@@ -130,10 +135,11 @@ def test_multiple_transformations
130135 expected = {
131136 src : "https://ik.imagekit.io/demo/sample.jpg?tr=h-300:e-bgremove:w-1080,c-at_max" ,
132137 src_set : "https://ik.imagekit.io/demo/sample.jpg?tr=h-300:e-bgremove:w-640,c-at_max 1x, https://ik.imagekit.io/demo/sample.jpg?tr=h-300:e-bgremove:w-1080,c-at_max 2x" ,
133- width : 450
138+ sizes : nil ,
139+ width : 450.0
134140 }
135141
136- assert_equal ( expected , result )
142+ assert_equal ( expected , result . to_h )
137143 end
138144
139145 def test_sizes_causes_breakpoint_pruning_33vw_path
@@ -147,10 +153,11 @@ def test_sizes_causes_breakpoint_pruning_33vw_path
147153 expected = {
148154 src : "https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max" ,
149155 src_set : "https://ik.imagekit.io/demo/sample.jpg?tr=w-256,c-at_max 256w, https://ik.imagekit.io/demo/sample.jpg?tr=w-384,c-at_max 384w, https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w" ,
150- sizes : "(min-width: 800px) 33vw, 100vw"
156+ sizes : "(min-width: 800px) 33vw, 100vw" ,
157+ width : nil
151158 }
152159
153- assert_equal ( expected , result )
160+ assert_equal ( expected , result . to_h )
154161 end
155162
156163 def test_using_query_parameters_and_transformation_position
@@ -170,10 +177,11 @@ def test_using_query_parameters_and_transformation_position
170177 expected = {
171178 src : "https://ik.imagekit.io/demo/tr:h-300:e-bgremove:w-1080,c-at_max/sample.jpg?key=value" ,
172179 src_set : "https://ik.imagekit.io/demo/tr:h-300:e-bgremove:w-640,c-at_max/sample.jpg?key=value 1x, https://ik.imagekit.io/demo/tr:h-300:e-bgremove:w-1080,c-at_max/sample.jpg?key=value 2x" ,
173- width : 450
180+ sizes : nil ,
181+ width : 450.0
174182 }
175183
176- assert_equal ( expected , result )
184+ assert_equal ( expected , result . to_h )
177185 end
178186
179187 def test_fallback_when_no_usable_vw_tokens
@@ -187,9 +195,10 @@ def test_fallback_when_no_usable_vw_tokens
187195 expected = {
188196 src : "https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max" ,
189197 src_set : "https://ik.imagekit.io/demo/sample.jpg?tr=w-16,c-at_max 16w, https://ik.imagekit.io/demo/sample.jpg?tr=w-32,c-at_max 32w, https://ik.imagekit.io/demo/sample.jpg?tr=w-48,c-at_max 48w, https://ik.imagekit.io/demo/sample.jpg?tr=w-64,c-at_max 64w, https://ik.imagekit.io/demo/sample.jpg?tr=w-96,c-at_max 96w, https://ik.imagekit.io/demo/sample.jpg?tr=w-128,c-at_max 128w, https://ik.imagekit.io/demo/sample.jpg?tr=w-256,c-at_max 256w, https://ik.imagekit.io/demo/sample.jpg?tr=w-384,c-at_max 384w, https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w" ,
190- sizes : "100%"
198+ sizes : "100%" ,
199+ width : nil
191200 }
192201
193- assert_equal ( expected , result )
202+ assert_equal ( expected , result . to_h )
194203 end
195204end
0 commit comments