diff options
Diffstat (limited to 't/tests')
-rw-r--r-- | t/tests/sietima/role/nomail.t | 48 | ||||
-rw-r--r-- | t/tests/sietima/role/replyto.t | 113 |
2 files changed, 147 insertions, 14 deletions
diff --git a/t/tests/sietima/role/nomail.t b/t/tests/sietima/role/nomail.t index fe64e84..a0be192 100644 --- a/t/tests/sietima/role/nomail.t +++ b/t/tests/sietima/role/nomail.t @@ -5,20 +5,40 @@ use 5.024; use lib 't/lib'; use Test::Sietima; -my $s = make_sietima( - with_traits => ['NoMail'], - subscribers => [ - { - raw_address => 'one@users.example.com', - wants_mail => 0, - }, - 'two@users.example.com', - ], -); +subtest 'disabled' => sub { + my $s = make_sietima( + with_traits => ['NoMail'], + subscribers => [ + { + address => 'one@users.example.com', + wants_mail => 0, + }, + 'two@users.example.com', + ], + ); -test_sending( - sietima => $s, - to => ['two@users.example.com'], -); + test_sending( + sietima => $s, + to => ['two@users.example.com'], + ); +}; + +subtest 'enabled' => sub { + my $s = make_sietima( + with_traits => ['NoMail'], + subscribers => [ + { + address => 'one@users.example.com', + wants_mail => 1, + }, + 'two@users.example.com', + ], + ); + + test_sending( + sietima => $s, + to => ['one@users.example.com','two@users.example.com'], + ); +}; done_testing; diff --git a/t/tests/sietima/role/replyto.t b/t/tests/sietima/role/replyto.t new file mode 100644 index 0000000..1bd2d02 --- /dev/null +++ b/t/tests/sietima/role/replyto.t @@ -0,0 +1,113 @@ +#!perl +use strict; +use warnings; +use 5.024; +use lib 't/lib'; +use Test::Sietima; + +subtest 'disabled' => sub { + my $s = make_sietima( + with_traits => ['ReplyTo'], + munge_reply_to => 0, + subscribers => [ + 'one@users.example.com', + 'two@users.example.com', + ], + ); + + test_sending( + sietima => $s, + mails => [ + object { + call [ header_str => 'reply-to' ] => undef; + }, + ], + ); +}; + +subtest 'enabled' => sub { + my $s = make_sietima( + with_traits => ['ReplyTo'], + munge_reply_to => 1, + subscribers => [ + 'one@users.example.com', + 'two@users.example.com', + ], + ); + + test_sending( + sietima => $s, + mails => [ + object { + call [ header_str => 'reply-to' ] => $s->return_path->address; + }, + ], + ); +}; + +subtest 'enabled for some' => sub { + my $s = make_sietima( + with_traits => ['ReplyTo'], + munge_reply_to => 0, + subscribers => [ + { + address => 'one@users.example.com', + munge_reply_to => 1, + }, + 'two@users.example.com', + ], + ); + + test_sending( + sietima => $s, + mails => [ + { + o => object { + call [ header_str => 'reply-to' ] => $s->return_path->address; + }, + to => [ 'one@users.example.com' ], + }, + { + o => object { + call [ header_str => 'reply-to' ] => undef; + }, + to => [ 'two@users.example.com' ], + }, + ], + ); +}; + + +subtest 'disabled for some' => sub { + my $s = make_sietima( + with_traits => ['ReplyTo'], + munge_reply_to => 1, + subscribers => [ + { + address => 'one@users.example.com', + munge_reply_to => 0, + }, + 'two@users.example.com', + ], + ); + + test_sending( + sietima => $s, + mails => [ + { + o => object { + call [ header_str => 'reply-to' ] => $s->return_path->address; + }, + to => [ 'two@users.example.com' ], + }, + { + o => object { + call [ header_str => 'reply-to' ] => undef; + }, + to => [ 'one@users.example.com' ], + }, + ], + ); +}; + +done_testing; |