diff options
Diffstat (limited to 't')
-rw-r--r-- | t/tests/sietima/role/subject-tag.t | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/t/tests/sietima/role/subject-tag.t b/t/tests/sietima/role/subject-tag.t new file mode 100644 index 0000000..6dc579a --- /dev/null +++ b/t/tests/sietima/role/subject-tag.t @@ -0,0 +1,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; |