diff options
author | Paul Schoenfelder <paulschoenfelder@gmail.com> | 2013-12-07 15:37:25 -0600 |
---|---|---|
committer | Paul Schoenfelder <paulschoenfelder@gmail.com> | 2013-12-07 15:37:25 -0600 |
commit | b520515fa7d5c0a30a288a3faeff6968296caa90 (patch) | |
tree | 1c2c37430a68110a814a7123867238082539d772 /test | |
parent | Refactor commands.ex to fix import issues (diff) |
Update tests
Diffstat (limited to 'test')
-rw-r--r-- | test/utils_test.exs | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/test/utils_test.exs b/test/utils_test.exs index cfd7cfb..6af5c25 100644 --- a/test/utils_test.exs +++ b/test/utils_test.exs @@ -1,16 +1,35 @@ defmodule ExIrc.UtilsTest do use ExUnit.Case + + use Irc.Commands + alias ExIrc.Utils, as: Utils alias ExIrc.Client.IrcMessage, as: IrcMessage + alias ExIrc.Client.ClientState, as: ClientState test "Given a local date/time as a tuple, can retrieve get the CTCP formatted time" do - local_time = {{2013,12,6},{14,5,00}} + local_time = {{2013,12,6},{14,5,00}} # Mimics output of :calendar.local_time() assert Utils.ctcp_time(local_time) == 'Fri Dec 06 14:05:00 2013' end test "Can parse an IRC message" do - message = ':irc.example.org 005 nick PREFIX=(ov)@+ CHANTYPES=#&' - assert IrcMessage[server: 'irc.example.org', cmd: '005', args: ['nick', 'PREFIX=(ov)@+', 'CHANTYPES=#&']] = Utils.parse(message) + message = ':irc.example.org 005 nick NETWORK=Freenode PREFIX=(ov)@+ CHANTYPES=#&' + assert IrcMessage[ + server: 'irc.example.org', + cmd: @rpl_isupport, + args: ['nick', 'NETWORK=Freenode', 'PREFIX=(ov)@+', 'CHANTYPES=#&'] + ] = Utils.parse(message) + end + + test "Can parse RPL_ISUPPORT commands" do + message = ':irc.example.org 005 nick NETWORK=Freenode PREFIX=(ov)@+ CHANTYPES=#&' + parsed = Utils.parse(message) + state = ClientState.new() + assert ClientState[ + channel_prefixes: [?#, ?&], + user_prefixes: [{?o, ?@}, {?v, ?+}], + network: 'Freenode' + ] = Utils.isup(parsed.args, state) end end |