Skip to content

Commit a6514d9

Browse files
committed
Fix tests
1 parent bc64e7b commit a6514d9

File tree

2 files changed

+70
-27
lines changed

2 files changed

+70
-27
lines changed

lib/petal_components/chat_bubble.ex

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ defmodule PetalComponents.ChatBubble do
101101
<img :if={@avatar_src} class="w-8 h-8 rounded-full" src={@avatar_src} alt={@avatar_alt} />
102102
<div class="flex flex-col w-full max-w-[320px] leading-1.5 p-4 border-gray-200 bg-gray-100 rounded-e-xl rounded-es-xl dark:bg-gray-700">
103103
{render_header(assigns)}
104-
<p :if={@message} class="text-sm font-normal py-2.5 text-gray-900 dark:text-white">{@message}</p>
104+
<p :if={@message} class="text-sm font-normal py-2.5 text-gray-900 dark:text-white">
105+
{@message}
106+
</p>
105107
<span class="text-sm font-normal text-gray-500 dark:text-gray-400">Delivered</span>
106108
</div>
107109
</div>
@@ -474,7 +476,9 @@ defmodule PetalComponents.ChatBubble do
474476
<img :if={@avatar_src} class="w-8 h-8 rounded-full" src={@avatar_src} alt={@avatar_alt} />
475477
<div class="flex flex-col w-full max-w-[320px] leading-1.5 p-4 border-gray-200 bg-gray-100 rounded-e-xl rounded-es-xl dark:bg-gray-700">
476478
{render_header(assigns)}
477-
<p :if={@message} class="text-sm font-normal py-2.5 text-gray-900 dark:text-white">{@message}</p>
479+
<p :if={@message} class="text-sm font-normal py-2.5 text-gray-900 dark:text-white">
480+
{@message}
481+
</p>
478482
<p class="text-sm font-normal pb-2.5 text-gray-900 dark:text-white">
479483
<a
480484
href={@url}
@@ -535,7 +539,9 @@ defmodule PetalComponents.ChatBubble do
535539
<div class="flex flex-col gap-1">
536540
{render_header(assigns)}
537541
<div class="flex flex-col w-full max-w-[326px] leading-1.5 p-4 border-gray-200 bg-gray-100 rounded-e-xl rounded-es-xl dark:bg-gray-700">
538-
<p :if={@message} class="text-sm font-normal py-2.5 text-gray-900 dark:text-white">{@message}</p>
542+
<p :if={@message} class="text-sm font-normal py-2.5 text-gray-900 dark:text-white">
543+
{@message}
544+
</p>
539545
</div>
540546
<span class="text-sm font-normal text-gray-500 dark:text-gray-400">Delivered</span>
541547
</div>
@@ -555,7 +561,7 @@ defmodule PetalComponents.ChatBubble do
555561
|> assign(:rest, assigns[:rest])
556562

557563
~H"""
558-
<div {@rest} class={["pc-chat-bubble", "pc-chat-bubble--outline-voice_note", @class]}>
564+
<div {@rest} class={["pc-chat-bubble", "pc-chat-bubble--outline-voice-note", @class]}>
559565
<div class="flex items-start gap-2.5">
560566
<img :if={@avatar_src} class="w-8 h-8 rounded-full" src={@avatar_src} alt={@avatar_alt} />
561567
<div class="flex flex-col gap-1 w-full max-w-[326px]">
@@ -780,7 +786,9 @@ defmodule PetalComponents.ChatBubble do
780786
<img :if={@avatar_src} class="w-8 h-8 rounded-full" src={@avatar_src} alt={@avatar_alt} />
781787
<div class="flex flex-col gap-1">
782788
{render_header(assigns)}
783-
<p :if={@message} class="text-sm font-normal text-gray-900 dark:text-white max-w-[326px]">{@message}</p>
789+
<p :if={@message} class="text-sm font-normal text-gray-900 dark:text-white max-w-[326px]">
790+
{@message}
791+
</p>
784792
<div class="flex flex-col w-full max-w-[326px] leading-1.5 p-2 border-gray-200 bg-gray-100 rounded-e-xl rounded-es-xl dark:bg-gray-700">
785793
<%!-- Image Grid --%>
786794
<div class="grid gap-4 grid-cols-2 my-2.5">
@@ -895,7 +903,9 @@ defmodule PetalComponents.ChatBubble do
895903
<img :if={@avatar_src} class="w-8 h-8 rounded-full" src={@avatar_src} alt={@avatar_alt} />
896904
<div class="flex flex-col gap-1 w-full max-w-[320px]">
897905
{render_header(assigns)}
898-
<p :if={@message} class="text-sm font-normal py-2.5 text-gray-900 dark:text-white">{@message}</p>
906+
<p :if={@message} class="text-sm font-normal py-2.5 text-gray-900 dark:text-white">
907+
{@message}
908+
</p>
899909
<div class="flex flex-col w-full leading-1.5 p-4 border-gray-200 bg-gray-100 rounded-e-xl rounded-es-xl dark:bg-gray-700">
900910
<p class="text-sm font-normal pb-2.5 text-gray-900 dark:text-white">
901911
<a
@@ -957,7 +967,9 @@ defmodule PetalComponents.ChatBubble do
957967
<img :if={@avatar_src} class="w-8 h-8 rounded-full" src={@avatar_src} alt={@avatar_alt} />
958968
<div class="flex flex-col w-full max-w-[320px] leading-1.5">
959969
{render_header(assigns)}
960-
<p :if={@message} class="text-sm font-normal py-2.5 text-gray-900 dark:text-white">{@message}</p>
970+
<p :if={@message} class="text-sm font-normal py-2.5 text-gray-900 dark:text-white">
971+
{@message}
972+
</p>
961973
<span class="text-sm font-normal text-gray-500 dark:text-gray-400">Delivered</span>
962974
</div>
963975
</div>
@@ -976,7 +988,7 @@ defmodule PetalComponents.ChatBubble do
976988
|> assign(:rest, assigns[:rest])
977989

978990
~H"""
979-
<div {@rest} class={["pc-chat-bubble", "pc-chat-bubble--clean-voice_note", @class]}>
991+
<div {@rest} class={["pc-chat-bubble", "pc-chat-bubble--clean-voice-note", @class]}>
980992
<div class="flex items-start gap-2.5">
981993
<img :if={@avatar_src} class="w-8 h-8 rounded-full" src={@avatar_src} alt={@avatar_alt} />
982994
<div class="flex flex-col w-full max-w-[320px] leading-1.5">
@@ -1193,7 +1205,9 @@ defmodule PetalComponents.ChatBubble do
11931205
<img class="w-8 h-8 rounded-full" src={@avatar_src} alt={@avatar_alt} />
11941206
<div class="flex flex-col gap-1">
11951207
{render_header(assigns)}
1196-
<p :if={@message} class="text-sm font-normal text-gray-900 dark:text-white max-w-[326px]">{@message}</p>
1208+
<p :if={@message} class="text-sm font-normal text-gray-900 dark:text-white max-w-[326px]">
1209+
{@message}
1210+
</p>
11971211
<div class="flex flex-col w-full max-w-[326px] leading-1.5 p-2">
11981212
<%!-- Image Grid with Tooltips --%>
11991213
<div class="grid gap-4 grid-cols-2 my-2.5">
@@ -1310,7 +1324,9 @@ defmodule PetalComponents.ChatBubble do
13101324
<img class="w-8 h-8 rounded-full" src={@avatar_src} alt={@avatar_alt} />
13111325
<div class="flex flex-col w-full max-w-[320px] leading-1.5">
13121326
{render_header(assigns)}
1313-
<p :if={@message} class="text-sm font-normal py-2.5 text-gray-900 dark:text-white">{@message}</p>
1327+
<p :if={@message} class="text-sm font-normal py-2.5 text-gray-900 dark:text-white">
1328+
{@message}
1329+
</p>
13141330
<p class="text-sm font-normal pb-2.5 text-gray-900 dark:text-white">
13151331
<a
13161332
href={@url}

test/petal/chat_bubble_test.exs

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ defmodule PetalComponents.ChatBubbleTest do
2222

2323
html =
2424
rendered_to_string(~H"""
25-
<.chat_bubble kind={:voicenote} author="Voice User" time="15:20" duration="2:15" />
25+
<.chat_bubble kind={:voice_note} author="Voice User" time="15:20" duration="2:15" />
2626
""")
2727

2828
assert html =~ "Voice User"
@@ -133,7 +133,8 @@ defmodule PetalComponents.ChatBubbleTest do
133133
html =
134134
rendered_to_string(~H"""
135135
<.chat_bubble
136-
kind={:outline_chat_bubble}
136+
kind={:chat_bubble}
137+
variant={:outline}
137138
author="Outline User"
138139
time="20:00"
139140
message="Outline message"
@@ -147,18 +148,24 @@ defmodule PetalComponents.ChatBubbleTest do
147148
assert html =~ "pc-chat-bubble--outline-chat-bubble"
148149
end
149150

150-
test "outline voicenote chat bubble" do
151+
test "outline voice note chat bubble" do
151152
assigns = %{}
152153

153154
html =
154155
rendered_to_string(~H"""
155-
<.chat_bubble kind={:outline_voicenote} author="Outline Voice User" time="23:00" duration="3:00" />
156+
<.chat_bubble
157+
kind={:voice_note}
158+
variant={:outline}
159+
author="Outline Voice User"
160+
time="23:00"
161+
duration="3:00"
162+
/>
156163
""")
157164

158165
assert html =~ "Outline Voice User"
159166
assert html =~ "23:00"
160167
assert html =~ "3:00"
161-
assert html =~ "pc-chat-bubble--outline-voicenote"
168+
assert html =~ "pc-chat-bubble--outline-voice-note"
162169
assert html =~ ~s(<svg class="w-[145px] md:w-[185px] md:h-[40px]")
163170
assert html =~ ~s(<button class="inline-flex self-center items-center p-2)
164171
end
@@ -169,7 +176,8 @@ defmodule PetalComponents.ChatBubbleTest do
169176
html =
170177
rendered_to_string(~H"""
171178
<.chat_bubble
172-
kind={:outline_file_attachment}
179+
kind={:file_attachment}
180+
variant={:outline}
173181
author="Outline File User"
174182
time="00:00"
175183
file_name="Outline File.pdf"
@@ -195,7 +203,8 @@ defmodule PetalComponents.ChatBubbleTest do
195203
html =
196204
rendered_to_string(~H"""
197205
<.chat_bubble
198-
kind={:outline_image_attachment}
206+
kind={:image_attachment}
207+
variant={:outline}
199208
author="Outline Image User"
200209
time="01:00"
201210
image_src="https://example.com/outline_image.jpg"
@@ -216,7 +225,8 @@ defmodule PetalComponents.ChatBubbleTest do
216225
html =
217226
rendered_to_string(~H"""
218227
<.chat_bubble
219-
kind={:outline_image_gallery}
228+
kind={:image_gallery}
229+
variant={:outline}
220230
author="Outline Gallery User"
221231
time="01:00"
222232
images={[
@@ -243,7 +253,8 @@ defmodule PetalComponents.ChatBubbleTest do
243253
html =
244254
rendered_to_string(~H"""
245255
<.chat_bubble
246-
kind={:outline_url_preview_sharing}
256+
kind={:url_preview_sharing}
257+
variant={:outline}
247258
author="Outline URL User"
248259
time="22:00"
249260
url="https://example.com"
@@ -269,7 +280,13 @@ defmodule PetalComponents.ChatBubbleTest do
269280

270281
html =
271282
rendered_to_string(~H"""
272-
<.chat_bubble kind={:clean_chat_bubble} author="Clean User" time="21:00" message="Clean message" />
283+
<.chat_bubble
284+
kind={:chat_bubble}
285+
variant={:clean}
286+
author="Clean User"
287+
time="21:00"
288+
message="Clean message"
289+
/>
273290
""")
274291

275292
assert html =~ "Clean User"
@@ -279,18 +296,24 @@ defmodule PetalComponents.ChatBubbleTest do
279296
assert html =~ "pc-chat-bubble--clean-chat-bubble"
280297
end
281298

282-
test "clean voicenote chat bubble" do
299+
test "clean voice note chat bubble" do
283300
assigns = %{}
284301

285302
html =
286303
rendered_to_string(~H"""
287-
<.chat_bubble kind={:clean_voicenote} author="Clean Voice User" time="23:00" duration="3:00" />
304+
<.chat_bubble
305+
kind={:voice_note}
306+
variant={:clean}
307+
author="Clean Voice User"
308+
time="23:00"
309+
duration="3:00"
310+
/>
288311
""")
289312

290313
assert html =~ "Clean Voice User"
291314
assert html =~ "23:00"
292315
assert html =~ "3:00"
293-
assert html =~ "pc-chat-bubble--clean-voicenote"
316+
assert html =~ "pc-chat-bubble--clean-voice-note"
294317
assert html =~ ~s(<svg class="w-[145px] md:w-[185px] md:h-[40px]")
295318
assert html =~ ~s(<button class="inline-flex self-center items-center p-2)
296319
end
@@ -301,7 +324,8 @@ defmodule PetalComponents.ChatBubbleTest do
301324
html =
302325
rendered_to_string(~H"""
303326
<.chat_bubble
304-
kind={:clean_file_attachment}
327+
kind={:file_attachment}
328+
variant={:clean}
305329
author="Clean File User"
306330
time="00:00"
307331
file_name="Clean File.pdf"
@@ -327,7 +351,8 @@ defmodule PetalComponents.ChatBubbleTest do
327351
html =
328352
rendered_to_string(~H"""
329353
<.chat_bubble
330-
kind={:clean_image_attachment}
354+
kind={:image_attachment}
355+
variant={:clean}
331356
author="Clean Image User"
332357
time="02:00"
333358
image_src="https://example.com/clean_image.jpg"
@@ -348,7 +373,8 @@ defmodule PetalComponents.ChatBubbleTest do
348373
html =
349374
rendered_to_string(~H"""
350375
<.chat_bubble
351-
kind={:clean_image_gallery}
376+
kind={:image_gallery}
377+
variant={:clean}
352378
author="Clean Gallery User"
353379
time="03:00"
354380
images={[
@@ -375,7 +401,8 @@ defmodule PetalComponents.ChatBubbleTest do
375401
html =
376402
rendered_to_string(~H"""
377403
<.chat_bubble
378-
kind={:clean_url_preview_sharing}
404+
kind={:url_preview_sharing}
405+
variant={:clean}
379406
author="Clean URL User"
380407
time="02:00"
381408
url="https://example.com"

0 commit comments

Comments
 (0)