summaryrefslogtreecommitdiff
path: root/t/email.t
blob: 0bc40df8810d266e6233c5e1ff0adb280b692296 (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
48
49
50
51
52
53
54
#!raku 
use v6.d;
use Test;
use MaildirIndexer::Email;
 
subtest 'no values' => {
    my $email = MaildirIndexer::Email.new(
        headers => %(),
        body => '',
    );
 
    is-deeply $email.message-id'''message id should parse';
    is-deeply $email.refs@(), 'refs should parse';
    is-deeply $email.addresses@(), 'addresses should parse';
}
 
subtest 'bad values' => {
    my $email = MaildirIndexer::Email.new(
        headers => %(
            message-id => 'some stuff here',
            in-reply-to => 'none',
            references => 'bad garbage',
            reply-to => 'random <stuff> @',
            from => 'not@ @an.address',
        ),
        body => '',
    );
 
    is-deeply $email.message-id'''message id should parse';
    is-deeply $email.refs@(), 'refs should parse';
    is-deeply $email.addresses@(), 'addresses should parse';
}
 
subtest 'all values' => {
    my $email = MaildirIndexer::Email.new(
        headers => %(
            message-id => 'some <stuff> here',
            in-reply-to => '<one>',
            references => 'bad <two> garbage <three>',
            reply-to => 'foo <one@me>',
            from => 'me@my.domain',
            to => 'one <one@your.domain>, two <two@their.domain>, etc',
        ),
        body => '',
    );
 
    is-deeply $email.message-id'stuff''message id should parse';
    is-deeply $email.refsqw[one three two]'refs should parse';
    is-deeply( $email.addresses.sort,
               @('me@my.domain','one@me','one@your.domain','two@their.domain'),
               'addresses should parse' );
}
 
done-testing;