aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2017-03-24 17:56:22 +0000
committerdakkar <dakkar@thenautilus.net>2017-03-24 17:56:22 +0000
commit144ca83dff443539f84b10c4571de3354c1fd65b (patch)
tree460bd3c5ce7a1eb7b0f8552b05bee3a00025c597 /t
parentname the authors of Siesta (diff)
downloadSietima-144ca83dff443539f84b10c4571de3354c1fd65b.tar.gz
Sietima-144ca83dff443539f84b10c4571de3354c1fd65b.tar.bz2
Sietima-144ca83dff443539f84b10c4571de3354c1fd65b.zip
documentation and tests for HeaderURI
Diffstat (limited to 't')
-rw-r--r--t/tests/sietima/headeruri.t80
1 files changed, 80 insertions, 0 deletions
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,
+ '<http://foo/> (a thing)',
+ 'normal constructor call',
+ );
+
+ is(
+ Sietima::HeaderURI->new(
+ '(comment) address@example.com',
+ )->as_header_raw,
+ '<mailto:address@example.com> (comment)',
+ 'string, address+comment',
+ );
+
+ is(
+ Sietima::HeaderURI->new(
+ 'http://some/url'
+ )->as_header_raw,
+ '<http://some/url>',
+ 'string, URI',
+ );
+
+ is(
+ Sietima::HeaderURI->new(
+ { scheme => 'https', host => 'foo', path => [1,2,3] }
+ )->as_header_raw,
+ '<https://foo/1/2/3>',
+ 'hashref, URI::FromHash',
+ );
+
+ is(
+ Sietima::HeaderURI->new(
+ URI->new('http://bar')
+ )->as_header_raw,
+ '<http://bar>',
+ 'URI object',
+ );
+
+ is(
+ Sietima::HeaderURI->new(
+ Email::Address->parse('(comment) address@example.com'),
+ )->as_header_raw,
+ '<mailto:address@example.com> (comment)',
+ 'Email::Address object',
+ );
+};
+
+
+subtest 'new_from_address' => sub {
+
+ is(
+ Sietima::HeaderURI->new_from_address(
+ '(comment) address@example.com',
+ )->as_header_raw,
+ '<mailto:address@example.com> (comment)',
+ 'string',
+ );
+
+ is(
+ Sietima::HeaderURI->new_from_address(
+ '(comment) address@example.com',
+ { subject => 'test me' },
+ )->as_header_raw,
+ '<mailto:address@example.com?subject=test+me> (comment)',
+ 'string and hashref',
+ );
+};
+
+done_testing;