Skip to content

Commit

Permalink
Add rountrip test for simple email
Browse files Browse the repository at this point in the history
GH rjbs#52

Show a regression introduced by commit ed7c290
which is using Email::Adress::XS to format the email
which result in stripping the 'angle brackets' around
an email when not using a 'phrase' for the email.

Previous behavior was preserving the '<quoted@email>'.
  • Loading branch information
atoomic committed Sep 6, 2017
1 parent aa63312 commit 9107810
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions t/simple-roundtrip.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use strict;
use warnings;
use Test::More;
use Encode;

BEGIN {
plan skip_all => 'Email::Address::XS is required for this test'
unless eval { require Email::Address::XS };
plan 'no_plan';
}

BEGIN {
use_ok('Email::MIME::Encode');
}

ok !$INC{'Email/MIME/Header.pm'}, 'Email::MIME::Header not loaded';

my @emails = ( q[<[email protected]>], q[[email protected]],
q["My Name" <[email protected]>] );

foreach my $iter ( 1 .. 2 ) {
my $txt =
$iter == 1
? 'Email::MIME::Header is not loaded'
: 'Email::MIME::Header is loaded';

foreach my $email (@emails) {
my $roundtrip = Email::MIME::Encode::maybe_mime_encode_header(
To => $email,
"utf-8"
);
is $roundtrip, $email, "preserve original email when $txt";
}

use_ok('Email::MIME::Header') if $iter == 1;

}

0 comments on commit 9107810

Please sign in to comment.