diff --git a/test/dsl/form_test.exs b/test/dsl/form_test.exs new file mode 100644 index 0000000..8586ae0 --- /dev/null +++ b/test/dsl/form_test.exs @@ -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{} + 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{} + assert result =~ ~s{} + 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{} + end + end +end diff --git a/test/dsl/html_test.exs b/test/dsl/html_test.exs index 423d9d2..7d022cc 100644 --- a/test/dsl/html_test.exs +++ b/test/dsl/html_test.exs @@ -210,55 +210,4 @@ defmodule Dsl.HtmlTest do ~s{
} 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{} - 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{} - assert result =~ ~s{} - 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{} - end - end end