summaryrefslogtreecommitdiff
path: root/test/parser/line_parser.exs
blob: efa0194df28135fc5b9d4c70693d502c550b7c33 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
defmodule Irc.Parser.LineTest do
  use ExUnit.Case
  alias Irc.Parser.Line
  doctest Irc.Parser.Line

  test "isupport" do
    line = ':nowhere 005 hrhrhr TOPICLEN=390 TARGMAX=NAMES:1,MONITOR: EXTBAN=$,acjorsxz CLIENTVER=3.0 :are supported by this server'
           |> Line.parse()
    assert line.source == "nowhere"
    assert line.command == "005"
    assert line.args == ["hrhrhr", "TOPICLEN=390", "TARGMAX=NAMES:1,MONITOR:", "EXTBAN=$,acjorsxz", "CLIENTVER=3.0", "are supported by this server"]
  end

  test "auth notice" do
    line = ':zoidberg.chatspike.net NOTICE Auth :Welcome to ChatSpike!'
           |> Line.parse()
    assert line.source == "zoidberg.chatspike.net"
    assert line.command =="NOTICE"
    assert line.args == ["Auth", "Welcome to ChatSpike!"]
  end

  test "connect notice" do
    line = ':livingstone.freenode.net NOTICE * :*** Checking Ident'
    |> Line.parse()
    assert line.command == "NOTICE"
    assert line.source == "livingstone.freenode.net"
    assert line.args == ["*", "*** Checking Ident"]
  end

  test "numeric" do
    line = ':stitch.chatspike.net 042 derp ABCDEFGHI :your unique ID'
           |> Line.parse
    assert line.source == "stitch.chatspike.net"
    assert line.command == "042"
    assert line.args == ["derp", "ABCDEFGHI", "your unique ID"]
  end

  test "ping" do
    line = 'PING :bender.chatspike.net'
           |> Line.parse
    assert line.command == "PING"
    assert line.args == ["bender.chatspike.net"]
  end

end