From 144ca83dff443539f84b10c4571de3354c1fd65b Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 24 Mar 2017 17:56:22 +0000 Subject: documentation and tests for HeaderURI --- t/tests/sietima/headeruri.t | 80 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 t/tests/sietima/headeruri.t (limited to 't') diff --git a/t/tests/sietima/headeruri.t b/t/tests/sietima/headeruri.t new file mode 100644 index 0000000..c158f3d --- /dev/null +++ b/t/tests/sietima/headeruri.t @@ -0,0 +1,80 @@ +#!perl +use lib 't/lib'; +use Test::Sietima; +use Email::Address; +use URI; +use Sietima::HeaderURI; + +subtest 'new' => sub { + is( + Sietima::HeaderURI->new({ + uri => 'http://foo/', + comment => 'a thing', + })->as_header_raw, + ' (a thing)', + 'normal constructor call', + ); + + is( + Sietima::HeaderURI->new( + '(comment) address@example.com', + )->as_header_raw, + ' (comment)', + 'string, address+comment', + ); + + is( + Sietima::HeaderURI->new( + 'http://some/url' + )->as_header_raw, + '', + 'string, URI', + ); + + is( + Sietima::HeaderURI->new( + { scheme => 'https', host => 'foo', path => [1,2,3] } + )->as_header_raw, + '', + 'hashref, URI::FromHash', + ); + + is( + Sietima::HeaderURI->new( + URI->new('http://bar') + )->as_header_raw, + '', + 'URI object', + ); + + is( + Sietima::HeaderURI->new( + Email::Address->parse('(comment) address@example.com'), + )->as_header_raw, + ' (comment)', + 'Email::Address object', + ); +}; + + +subtest 'new_from_address' => sub { + + is( + Sietima::HeaderURI->new_from_address( + '(comment) address@example.com', + )->as_header_raw, + ' (comment)', + 'string', + ); + + is( + Sietima::HeaderURI->new_from_address( + '(comment) address@example.com', + { subject => 'test me' }, + )->as_header_raw, + ' (comment)', + 'string and hashref', + ); +}; + +done_testing; -- cgit v1.2.3