Courriel

 view release on metacpan or  search on metacpan

t/Courriel.t  view on Meta::CPAN

use strict;
use warnings;

use Test::Differences;
use Test::Fatal;
use Test::More 0.88;
use Test::Warnings;

use Courriel;
use Courriel::Builder;
use Courriel::Helpers;
use Email::Address::XS;
use Encode qw( encode is_utf8 );
use Scalar::Util qw( blessed );

## no critic (InputOutput::RequireCheckedSyscalls)
binmode $_, ':encoding(UTF-8)'
    for map { Test::Builder->new->$_ }
    qw( output failure_output todo_output );
## use critic

my $crlf = $Courriel::Helpers::CRLF;

{
    my $text = <<'EOF';
Subject:

This is the body
EOF

    my $email = Courriel->parse( text => \$text );
    ok( defined $email->subject, 'empty subject is defined' );
}

{
    my $text = <<'EOF';
Subject: Foo

This is the body
EOF

    my $email = Courriel->parse( text => \$text );

    is( $email->subject, 'Foo', 'got the right subject' );

    is( $email->part_count, 1, 'email has one part' );

    is_deeply(
        _headers_as_arrayref($email),
        [
            Subject                     => 'Foo',
            'Content-Transfer-Encoding' => '8bit',
        ],
        'headers were parsed correctly'
    );

    my ($part) = $email->parts;
    is(
        $part->content_type->mime_type,
        'text/plain',
        'email with no content type defaults to text/plain'
    );

    is(



( run in 1.026 second using v1.01-cache-2.11-cpan-6aa56a78535 )