Skip to content
Permalink
Browse files

chore(tests): formatting

  • Loading branch information
geolessel committed Nov 19, 2019
1 parent 7046c61 commit a55d17ca93e5a7e513fb289d68d4a84f0d79f420
Showing with 30 additions and 7 deletions.
  1. +30 −7 test/react_phoenix/client_side_test.exs
@@ -8,17 +8,28 @@ defmodule ReactPhoenix.ClientSideTest do
end

test "react_component/1 returns a renderable div" do
html = Phoenix.HTML.safe_to_string(react_component("test"))
html =
"test"
|> react_component()
|> Phoenix.HTML.safe_to_string()

assert String.match?(html, ~r|^<div.*></div>$|)
end

test "react_component/1 returns a renderable div with data-react-class containing component name" do
html = Phoenix.HTML.safe_to_string(react_component("test"))
html =
"test"
|> react_component()
|> Phoenix.HTML.safe_to_string()

assert String.match?(html, ~r|data-react-class="test"|)
end

test "react_component/2 returns a renderable div with data-react-props containing props list" do
html = Phoenix.HTML.safe_to_string(react_component("test", my: "props"))
html =
"test"
|> react_component(my: "props")
|> Phoenix.HTML.safe_to_string()

expected =
"<div data-react-class=\"test\" data-react-props=\"{&quot;my&quot;:&quot;props&quot;}\"></div>"
@@ -27,7 +38,10 @@ defmodule ReactPhoenix.ClientSideTest do
end

test "react_component/2 returns a renderable div with data-react-props containing props map" do
html = Phoenix.HTML.safe_to_string(react_component("test", %{my: "props"}))
html =
"test"
|> react_component(%{my: "props"})
|> Phoenix.HTML.safe_to_string()

expected =
"<div data-react-class=\"test\" data-react-props=\"{&quot;my&quot;:&quot;props&quot;}\"></div>"
@@ -36,7 +50,10 @@ defmodule ReactPhoenix.ClientSideTest do
end

test "react_component/3 accepts a target div option" do
html = Phoenix.HTML.safe_to_string(react_component("test", %{}, target_id: "test-id"))
html =
"test"
|> react_component(%{}, target_id: "test-id")
|> Phoenix.HTML.safe_to_string()

expected =
"<div data-react-class=\"test\" data-react-props=\"{}\" data-react-target-id=\"test-id\"></div>"
@@ -45,7 +62,10 @@ defmodule ReactPhoenix.ClientSideTest do
end

test "react_component/3 accepts a html_element option" do
html = Phoenix.HTML.safe_to_string(react_component("test", %{}, html_element: :span))
html =
"test"
|> react_component(%{}, html_element: :span)
|> Phoenix.HTML.safe_to_string()

expected =
"<span data-react-class=\"test\" data-react-props=\"{}\" data-react-target-id=\"\"></span>"
@@ -54,7 +74,10 @@ defmodule ReactPhoenix.ClientSideTest do
end

test "react_component/3 passes on extra options to the html element" do
html = Phoenix.HTML.safe_to_string(react_component("test", %{}, class: "row", id: "content"))
html =
"test"
|> react_component(%{}, class: "row", id: "content")
|> Phoenix.HTML.safe_to_string()

expected =
"<div class=\"row\" data-react-class=\"test\" data-react-props=\"{}\" data-react-target-id=\"\" id=\"content\"></div>"

0 comments on commit a55d17c

Please sign in to comment.
You can’t perform that action at this time.