Move form tests to the proper test file

This commit is contained in:
Mitchell Hanberg 2019-05-11 23:30:16 -04:00
parent c4ebf81b6b
commit 3a435b1727
2 changed files with 55 additions and 51 deletions

55
test/dsl/form_test.exs Normal file
View file

@ -0,0 +1,55 @@
defmodule Dsl.FormTest do
use ExUnit.Case, async: true
use Dsl
describe "form_for" do
test "returns a form tag" do
conn = %Plug.Conn{}
action = "/"
{:safe, result} =
htm do
form_for(conn, action, [])
end
assert result =~ ~s{<form}
assert result =~ ~s{</form>}
end
test "can take a block" do
conn = %Plug.Conn{}
action = "/"
opts = []
{:safe, result} =
htm do
form_for conn, action, opts do
div()
end
end
assert result =~ ~s{<form}
assert result =~ ~s{<div></div>}
assert result =~ ~s{</form>}
end
test "can take a block that references the form" do
conn = %Plug.Conn{}
action = "/"
opts = []
{:safe, result} =
htm do
form_for conn, action, opts do
text_input(form, :bob)
end
end
assert result =~ ~s{<form}
assert result =~ ~s{<input}
assert result =~ ~s{type="text"}
assert result =~ ~s{name="bob"}
assert result =~ ~s{</form>}
end
end
end

View file

@ -210,55 +210,4 @@ defmodule Dsl.HtmlTest do
~s{<div data-controller="stimulus-controller" data-target="stimulus-target"></div>}
end
end
describe "form_for" do
test "returns a form tag" do
conn = %Plug.Conn{}
action = "/"
{:safe, result} =
htm do
form_for(conn, action, [])
end
assert result =~ ~s{<form}
assert result =~ ~s{</form>}
end
test "can take a block" do
conn = %Plug.Conn{}
action = "/"
opts = []
{:safe, result} =
htm do
form_for conn, action, opts do
div()
end
end
assert result =~ ~s{<form}
assert result =~ ~s{<div></div>}
assert result =~ ~s{</form>}
end
test "can take a block that references the form" do
conn = %Plug.Conn{}
action = "/"
opts = []
{:safe, result} =
htm do
form_for conn, action, opts do
text_input(form, :bob)
end
end
assert result =~ ~s{<form}
assert result =~ ~s{<input}
assert result =~ ~s{type="text"}
assert result =~ ~s{name="bob"}
assert result =~ ~s{</form>}
end
end
end