aboutsummaryrefslogtreecommitdiff
path: root/test/test_men.t
blob: 683accdcbdb01b1531cb551ad66e6521439d30af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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");
}