aboutsummaryrefslogtreecommitdiff
path: root/t/tests/sietima/subscriber.t
blob: 979997bd19900510264ac59efa63d6401227daba (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
#!perl 
use strict;
use warnings;
use 5.024;
use Test2::Bundle::Extended;
use Test2::Plugin::DieOnFail;
use Sietima::Subscriber;
 
subtest 'simple' => sub {
    my $s = Sietima::Subscriber->new(
        raw_address => 'Gino (pino) <gino@pino.example.com>',
    );
 
    is(
        $s,
        object {
            call address => 'gino@pino.example.com';
            call name => 'Gino';
            call original => 'Gino (pino) <gino@pino.example.com>';
            call prefs => {};
        },
        'construction and delegation should work',
    );
};
 
subtest 'aliases' => sub {
    my $s = Sietima::Subscriber->new(
        raw_address => 'Gino (pino) <gino@pino.example.com>',
        aliases => [qw(also-gino@pino.example.com maybe-gino@rino.example.com)],
    );
 
    is(
        $s,
        object {
            for my $a (qw(gino@pino also-gino@pino maybe-gino@rino)) {
                call [match => "${a}.example.com"] => T();
            }
        },
        'all addresses should ->match()',
    );
 
};
 
done_testing;