5 use Test::More tests => 15;
8 BEGIN { use_ok('POE::Component::IRC::Plugin::Hello') };
13 my $mockirc = Test::MockObject->new;
14 $mockirc->mock(yield => sub { $hello_sent = 1 })->set_always(nick_name => 'hellobot');
16 my $self = POE::Component::IRC::Plugin::Hello->new;
17 my $channels = [ '#chan' ];
21 my ($message, $expect, $comment) = @_;
23 $self->S_public($mockirc, \'mgv!marius@ieval.ro', \$channels, \$message);
24 ok($hello_sent == $expect, $comment)
28 runtest 'privet', 1, 'simple privet';
29 runtest 'PrIvEt', 1, 'privet in mixed case';
30 runtest ' privet ', 1, 'privet with spaces';
31 runtest 'hellobot: privet', 1, 'addressed privet';
32 runtest 'hellobot: privet ', 1, 'addressed privet with spaces';
33 runtest 'ahoy', 1, 'ahoy';
34 runtest 'namaste', 1, 'namaste';
35 runtest 'neaţa', 1, 'neaţa (UTF-8 test)';
36 runtest 'こんにちは', 1, 'こんにちは (another UTF-8 test)';
38 runtest 'salu', 0, 'salu (misspelling)';
39 runtest 'hii', 0, 'hii (misspelling)';
40 runtest 'neaţa mgv', 0, 'neaţa mgv (valid greeting with garbage after it)';
42 $self = POE::Component::IRC::Plugin::Hello->new(greetings => ['sayonara']);
44 runtest 'privet', 0, 'custom greetings - privet';
45 runtest ' sayonara ', 1, 'custom greetings - sayonara';