summaryrefslogtreecommitdiff
path: root/test/parser/prefix_test.exs
diff options
context:
space:
mode:
Diffstat (limited to 'test/parser/prefix_test.exs')
-rw-r--r--test/parser/prefix_test.exs39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/parser/prefix_test.exs b/test/parser/prefix_test.exs
new file mode 100644
index 0000000..bea651f
--- /dev/null
+++ b/test/parser/prefix_test.exs
@@ -0,0 +1,39 @@
+defmodule Irc.Parser.PrefixTest do
+ use ExUnit.Case
+ alias Irc.Parser.Prefix
+ doctest Irc.Parser.Prefix
+
+
+ @conn %Irc.Connection{isupport: %{"PREFIX" => %{"@" => "o", "+" => "v"}}}
+
+ test "who flags (lax)" do
+ assert Prefix.parse("H*@", @conn, true) == {["o"], "H*"}
+ end
+
+ test "lax, multiple" do
+ assert Prefix.parse("H*@+", @conn, true) == {["o", "v"], "H*"}
+ assert Prefix.parse("H*@+", @conn) == {[], "H*@+"}
+ end
+
+ test "not lax" do
+ assert Prefix.parse("@href", @conn) == {["o"], "href"}
+ end
+
+ test "not lax, multiple" do
+ assert Prefix.parse("@+href", @conn) == {["o", "v"], "href"}
+ end
+
+ test "not lax, prefix char in rest" do
+ assert Prefix.parse("@hr@f", @conn) == {["o"], "hr@f"}
+ end
+
+ test "no prefix, not lax" do
+ assert Prefix.parse("href", @conn) == {[], "href"}
+ end
+
+ test "no prefix, lax" do
+ assert Prefix.parse("href", @conn, true) == {[], "href"}
+ end
+
+
+end