aboutsummaryrefslogtreecommitdiff
path: root/test/test_men.t
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_men.t')
-rwxr-xr-xtest/test_men.t47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/test_men.t b/test/test_men.t
new file mode 100755
index 0000000..683accd
--- /dev/null
+++ b/test/test_men.t
@@ -0,0 +1,47 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::More tests => 4;
+use Mock::IRC;
+
+use Plugin::Men;
+
+my $irc = new Mock::IRC;
+
+my %config = (
+ chance => 100,
+);
+Plugin::Men->configure(undef, undef, \%config, undef);
+
+# Simplest test case, just message that reads `men`
+{
+ my $what = "men";
+ my $r = Plugin::Men->on_message(\&note, undef, undef, $what, $what, $irc);
+ ok($r =~ m/women.*children too/, "caught expected word");
+}
+
+# Simple test case, mid-word
+{
+ my $what = "foo comment bar";
+ my $r = Plugin::Men->on_message(\&note, undef, undef, $what, $what, $irc);
+ ok($r =~ m/comwoment.*comchildrent too/, "caught expected word");
+}
+
+# Case preservation on surrounding word
+# XXX rethink this behaviour - shouldn't it preserve case on whole word?
+{
+ my $what = "frongle COMMENT kleng";
+ my $r = Plugin::Men->on_message(\&note, undef, undef, $what, $what, $irc);
+ ok($r =~ m/COMwomenT.*COMchildrenT too/, "caught expected word");
+}
+
+# UTF-8 support
+{
+ my $what = "💯 testmen☭";
+ my $r = Plugin::Men->on_message(\&note, undef, undef, $what, $what, $irc);
+ # use utf8 after this point. Don't use it above, module does its own
+ # conversion for now because of how POE::Component::IRC passes data in
+ use utf8;
+ ok($r =~ m/testwomen.*testchildren too/, "caught expected word");
+}