@@ -195,4 +195,77 @@ defmodule PetalComponents.CarouselTest do
195
195
assert slide2_content =~ "href=\" https://github.com/petalframework/petal_components\" "
196
196
assert slide2_content =~ "class=\" pc-carousel__link\" "
197
197
end
198
+
199
+ test "Carousel with content positioning" do
200
+ assigns = % { }
201
+
202
+ html =
203
+ rendered_to_string ( ~H"""
204
+ < . carousel id = "test-carousel-7 " transition_type = "fade " >
205
+ <: slide
206
+ content_position = "start "
207
+ title = "Left Aligned Content "
208
+ description = "This content should be left-aligned "
209
+ image = "https://example.com/image1.jpg "
210
+ />
211
+ <: slide
212
+ content_position = "center "
213
+ title = "Center Aligned Content "
214
+ description = "This content should be centered "
215
+ image = "https://example.com/image2.jpg "
216
+ />
217
+ <: slide
218
+ content_position = "end "
219
+ title = "Right Aligned Content "
220
+ description = "This content should be right-aligned "
221
+ image = "https://example.com/image3.jpg "
222
+ />
223
+ </ . carousel >
224
+ """ )
225
+
226
+ # Check for proper content position classes
227
+ assert html =~ "items-start justify-start text-left"
228
+ assert html =~ "items-center justify-center text-center"
229
+ assert html =~ "items-end justify-end text-right"
230
+
231
+ # Verify content is present
232
+ assert html =~ "Left Aligned Content"
233
+ assert html =~ "Center Aligned Content"
234
+ assert html =~ "Right Aligned Content"
235
+ end
236
+
237
+ test "Carousel with slide containing no title" do
238
+ assigns = % { }
239
+
240
+ html =
241
+ rendered_to_string ( ~H"""
242
+ < . carousel id = "test-carousel-6 " transition_type = "fade " >
243
+ <: slide
244
+ image = "https://example.com/image1.jpg "
245
+ description = "This slide has a description but no title "
246
+ />
247
+ <: slide
248
+ image = "https://example.com/image2.jpg "
249
+ />
250
+ </ . carousel >
251
+ """ )
252
+
253
+ # Check that image is present
254
+ assert html =~ "https://example.com/image1.jpg"
255
+
256
+ # Check that description is present
257
+ assert html =~ "This slide has a description but no title"
258
+
259
+ # Check that no default title is added (should not have "Slide 1" text)
260
+ refute html =~ "Slide 1"
261
+ refute html =~ "Slide 2"
262
+
263
+ # The second slide should only have an image and no text content
264
+ slide2_content = html
265
+ |> String . split ( "pc-carousel__slide" )
266
+ |> Enum . at ( 2 )
267
+
268
+ assert slide2_content =~ "https://example.com/image2.jpg"
269
+ refute slide2_content =~ "pc-carousel__title"
270
+ end
198
271
end
0 commit comments