From 036729735fa125caadd2d8834a6501fc79b57374 Mon Sep 17 00:00:00 2001 From: Kamaro Date: Tue, 11 Jun 2024 17:21:18 +0300 Subject: [PATCH] Added testings for the badge --- test/salad_ui/badge_test.exs | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 test/salad_ui/badge_test.exs diff --git a/test/salad_ui/badge_test.exs b/test/salad_ui/badge_test.exs new file mode 100644 index 0000000..e4d041a --- /dev/null +++ b/test/salad_ui/badge_test.exs @@ -0,0 +1,66 @@ +defmodule SaladUI.BadgeTest do + use ComponentCase + import SaladUI.Badge + + describe "Test Badge" do + + test "It renders a badge default variant" do + assigns = %{} + + html = rendered_to_string( + ~H""" + <.badge>Badge + """ + ) + + for class <- ~w(inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent bg-primary text-primary-foreground hover:bg-primary/80) do + assert html =~ class + end + + assert html =~ "
Secondary + """ + ) + + for class <- ~w(border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80) do + assert html =~ class + end + end + + test "It renders a badge with the destructive variant" do + + assigns = %{} + html = rendered_to_string( + ~H""" + <.badge variant="destructive">Destructive + """ + ) + + for class <- ~w(border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80) do + assert html =~ class + end + assert html =~ "Destructive" + end + + test "it renders a badge with the outlined variant" do + assigns = %{} + html = rendered_to_string( + ~H""" + <.badge variant="outline">Outline + """ + ) + + for class <- ~w(text-foreground) do + assert html =~ class + end + assert html =~ "Outline" + end + end +end