aboutsummaryrefslogtreecommitdiff
path: root/t/tests/sietima/role/subject-tag.t
blob: 6dc579aadc79e299e120c5ef6885ea2ef73b2006 (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
55
56
57
58
59
60
61
62
#!perl 
use strict;
use warnings;
use 5.024;
use lib 't/lib';
use Test::Sietima;
 
my $s = make_sietima(
    with_traits => ['SubjectTag'],
    subscribers => [
        'one@users.example.com',
        'two@users.example.com',
    ],
    subject_tag => 'foo',
);
 
subtest 'adding tag' => sub {
    test_sending(
        sietima => $s,
    );
 
    is(
        [ transport->deliveries ],
        array {
            item hash {
                field email => object {
                    call [cast=>'Email::MIME'] => object {
                        call [ header_str => 'Subject' ] =>
                            '[foo] Test Message';
                    };
                };
            };
        },
        'subject tag should be added to all messages',
    );
};
 
subtest 'tag already there' => sub {
    test_sending(
        sietima => $s,
        mail => {
            subject => my $subject = "[foo] \N{HEAVY BLACK HEART} test",
        },
    );
 
    is(
        [ transport->deliveries ],
        array {
            item hash {
                field email => object {
                    call [cast=>'Email::MIME'] => object {
                        call [ header_str => 'Subject' ] =>
                            $subject;
                    };
                };
            };
        },
        'subject tag should not be duplicated',
    );
};
 
done_testing;