-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |