aboutsummaryrefslogtreecommitdiff
path: root/t/tests/sietima/headeruri.t
blob: c158f3df23bc3d63a6b18f3eb6178f897f41854a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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;