Packages
drab
0.2.6
0.10.5
0.10.4
0.10.3
0.10.2
0.10.1
0.10.0
0.9.3
0.9.2
0.9.1
0.9.0
0.8.3
0.8.2
0.8.1
0.8.0
0.7.7
0.7.6
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.3
0.6.2
0.6.1
0.6.0
0.6.0-pre.1
0.5.6
0.5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.4.1
0.4.0
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.1
0.1.0
Remote controlled frontend framework for Phoenix.
Current section
Files
Jump to
Current section
Files
test/drab/query_test.exs
defmodule Drab.QueryTest do
use ExUnit.Case, ascync: true
doctest Drab.Query
test "this/1 should return drab_id" do
dom_sender = %{ "drab_id" => "DRAB_ID"}
assert Drab.Query.this(dom_sender) == "[drab-id=DRAB_ID]"
end
test "this!/1 should return id" do
dom_sender = %{ "id" => "ID"}
assert Drab.Query.this!(dom_sender) == "#ID"
end
test "this!/1 should raise when there is no ID" do
dom_sender = %{ "drab_id" => "there is a DRAB_ID, but not actual id"}
assert_raise RuntimeError, ~r"Try to use Drab.Query.this!/1 on DOM object without an ID:", fn ->
Drab.Query.this!(dom_sender)
end
end
test "select/2 should raise on non-existing method" do
assert_raise RuntimeError, ~r"Drab does not recognize your query", fn ->
Drab.Query.select(nil, non_existing: :some_arguments, from: "")
end
end
test "select/3 should raise on non-existing method" do
assert_raise RuntimeError, ~r"Drab does not recognize your query", fn ->
Drab.Query.select(nil, :non_existing, from: "")
end
end
test "update/3 should raise on non-existing method" do
assert_raise RuntimeError, ~r"Drab does not recognize your query", fn ->
Drab.Query.update(nil, :non_existing, set: :something, on: "")
end
end
test "update/2 should raise on non-existing method" do
assert_raise RuntimeError, ~r"Drab does not recognize your query", fn ->
Drab.Query.update(nil, non_existing: :arguments, set: :something, on: "")
end
end
test "insert/2 should raise on non-existing insert method" do
assert_raise RuntimeError, ~r"Drab does not recognize your query", fn ->
Drab.Query.insert(nil, no_class: "pierwsza A", into: "")
end
end
test "insert/3 should raise on non-existing insert method" do
assert_raise RuntimeError, ~r"Drab does not recognize your query", fn ->
Drab.Query.insert(nil, "some html", something_else_than_after_of_before: "")
end
end
test "delete/2 should raise on non-existing delete method" do
assert_raise RuntimeError, ~r"Drab does not recognize your query", fn ->
Drab.Query.delete(nil, somewhere_wrong: "", from: "")
end
end
end