Initial release
[app-devbot.git] / t / App-Devbot.t
CommitLineData
bb1da1df
MG
1#!/usr/bin/perl -w
2use v5.14;
3use warnings;
4no warnings 'redefine';
5
6use Test::More tests => 11;
7BEGIN { use_ok('App::Devbot') };
8
9use POE;
10
11sub call_poe{
12 my ($func, @args)=@_;
13 my @arglist;
14 $arglist[ARG0 + $_]=$args[$_] for 0 .. $#args;
15 $func->(@arglist)
16}
17
18sub set_test{
19 my ($expected, $testname) = @_;
20 *App::Devbot::log_event = sub { shift; is "@_", $expected, $testname };
21}
22
23*App::Devbot::mode_char = sub { ' ' };
24
25set_test '< nick> Hello, world!', 'public';
26call_poe \&App::Devbot::on_public, 'nick!user@host', ['#channel'], 'Hello, world!';
27
28set_test '* nick nicked', 'action';
29call_poe \&App::Devbot::on_ctcp_action, 'nick!user@host', ['#channel'], 'nicked';
30
31set_test '-!- nick [user@host] has joined #channel', 'join';
32call_poe \&App::Devbot::on_join, 'nick!user@host', '#channel';
33
34set_test '-!- nick [user@host] has left #channel [Leaving!]', 'part';
35call_poe \&App::Devbot::on_part, 'nick!user@host', '#channel', 'Leaving!';
36
37set_test '-!- idiot was kicked from #channel by nick [no reason]', 'kick';
38call_poe \&App::Devbot::on_kick, 'nick!user@host', '#channel', 'idiot', 'no reason';
39
40set_test '-!- mode/#channel [+oo mgv mgvx] by ChanServ', 'mode';
41call_poe \&App::Devbot::on_mode, 'ChanServ!user@host', '#channel', '+oo', 'mgv', 'mgvx';
42
43set_test '-!- nick changed the topic of #channel to: Go away!', 'topic set';
44call_poe \&App::Devbot::on_topic, 'nick!user@host', '#channel', 'Go away!';
45
46set_test '-!- Topic unset by nick on #channel', 'topic unset';
47call_poe \&App::Devbot::on_topic, 'nick!user@host', '#channel', '';
48
49set_test '-!- nick is now known as newnick', 'nick';
50call_poe \&App::Devbot::on_nick, 'nick!user@host', 'newnick', ['#channel'];
51
52set_test '-!- nick [user@host] has quit [Quitting]', 'quit';
53call_poe \&App::Devbot::on_quit, 'nick!user@host', 'Quitting', ['#channel'];
This page took 0.011189 seconds and 4 git commands to generate.