Skip to content

Commit

Permalink
Added avatar and alert tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kamaroly committed Jun 11, 2024
1 parent 031168b commit 74babd6
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/salad_ui/avatar_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
defmodule SaladUI.AvatarTest do
use ComponentCase
import SaladUI.Avatar

describe "Test Avatar" do
test "It renders avatar image correctly" do
assigns = %{}

html = rendered_to_string(
~H"""
<.avatar_image src="https://github.com/shadcn.png" />
"""
)

assert html =~ "<img class=\"aspect-square w-full h-full\""
assert html =~ "src=\"https:\/\/github.com\/shadcn.png\" "
end

test "It renders fallback correctly" do
assigns = %{}
html = rendered_to_string(
~H"""
<.avatar_fallback class="bg-primary text-white">CN</.avatar_fallback>
"""
)

assert html =~ "<span class=\"flex rounded-full bg-primary text-white items-center justify-center w-full h-full\">"
assert html =~ "CN"
end

test "It renders avatar correctly" do
assigns = %{}
html = rendered_to_string(
~H"""
<.avatar>
<.avatar_image src="https://github.com/shadcn.png" />
<.avatar_fallback class="bg-primary text-white">CN</.avatar_fallback>
</.avatar>
"""
)

assert html =~ "<span class=\"flex rounded-full bg-primary text-white items-center justify-center w-full h-full\">"
assert html =~ "CN"
end
end
end

0 comments on commit 74babd6

Please sign in to comment.