aboutsummaryrefslogtreecommitdiff
path: root/test/test_thanks.t
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_thanks.t')
-rwxr-xr-xtest/test_thanks.t35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/test_thanks.t b/test/test_thanks.t
new file mode 100755
index 0000000..680c235
--- /dev/null
+++ b/test/test_thanks.t
@@ -0,0 +1,35 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::Simple tests => 8;
+use Mock::CommandRegistry;
+
+use Plugin::Thanks;
+
+my @expected_commands = qw/thanks thanks. thanks! thanks?/;
+
+my $cr = new Mock::CommandRegistry;
+my $register = sub { $cr->register(@_); };
+Plugin::Thanks->configure($register, undef, undef, undef);
+for my $cmd (@expected_commands) {
+ my $is_registered = $cr->is_registered_to_owner("Plugin::Thanks", $cmd);
+ ok($is_registered, "registered command $cmd");
+}
+
+my $thanker = "somelad";
+my %ctx = (
+ irc => undef,
+ logger => undef,
+ who => "$thanker!who\@example.com",
+ where => undef,
+ ided => undef,
+ rest => undef,
+ no_reenter => undef,
+ args => undef
+);
+my $expected = "$thanker: pong";
+for my $cmd (@expected_commands) {
+ my $response = $cr->run_owned("Plugin::Thanks", $cmd, %ctx);
+ ok($response =~ m/^\Q$thanker\E: /, "response addressed to thanker");
+}