added todo
[catagits/Catalyst-View-Email.git] / t / 05template.t
CommitLineData
82300460 1use strict;
2use warnings;
ce1977b0 3
4BEGIN { $ENV{EMAIL_SENDER_TRANSPORT} = 'Test' }
8b10ee55 5use Test::More;
82300460 6
ce1977b0 7use Email::Sender::Simple;
82300460 8use FindBin;
9use lib "$FindBin::Bin/lib";
10
11use_ok('Catalyst::Test', 'TestApp');
12
13my $response;
14my $time = time;
15ok( ( $response = request("/template_email?time=$time"))->is_success,
16 'request ok' );
ce1977b0 17my @emails = Email::Sender::Simple->default_transport->deliveries;
82300460 18like( $response->content, qr/Template Email Ok/, 'controller says ok' );
82300460 19cmp_ok(@emails, '==', 1, 'got emails');
ce1977b0 20isa_ok( $emails[0]->{'email'}, 'Email::Abstract', 'email is ok' );
ab4326b4 21
ce1977b0 22like($emails[0]->{'email'}[0]->header("Content-type"), qr#^multipart/alternative#, 'Multipart email');
ab4326b4 23
ce1977b0 24my @parts = $emails[0]->{'email'}[0]->parts;
82300460 25cmp_ok(@parts, '==', 2, 'got parts');
26
28151039 27is($parts[0]->content_type, 'text/plain', 'text/plain part ok');
fd0033bc 28like($parts[0]->body, qr/test-email\@example.com on $time/, 'got content back');
43090696 29
28151039 30is($parts[1]->content_type, 'text/html', 'text/html ok');
fd0033bc 31like($parts[1]->body, qr{<em>test-email\@example.com</em> on $time}, 'got content back');
82300460 32#like($emails[0]->body, qr/$time/, 'Got our email');
ce1977b0 33done_testing();