File: html_nested_anchors.t

package info (click to toggle)
spamassassin 4.0.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,732 kB
  • sloc: perl: 89,143; ansic: 5,193; sh: 3,737; javascript: 339; sql: 295; makefile: 209; python: 49
file content (45 lines) | stat: -rw-r--r-- 1,091 bytes parent folder | download
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
#!/usr/bin/perl -T
use strict;
use warnings;
use lib '.'; use lib 't';
use SATest; sa_t_init("html_nested_anchors");
use Mail::SpamAssassin::HTML;
use Test::More;

my @tests = (
    {
        html => '<a href="#one">foo<a href="#two">bar</a>baz</a>',
        uris => {
            '#one' => {
                types       => { 'a' => 1 },
                anchor_text => ['foobarbaz'],
            },
            '#two' => {
                types       => { 'a' => 1 },
                anchor_text => ['bar'],
            }
        }
    },
    {
        html => '<a href="#one">foo<a href="#one">bar</a>baz</a>',
        uris => {
            '#one' => {
                types       => { 'a' => 1 },
                anchor_text => ['foobarbaz', 'bar'],
            },
        }
    },
);

plan tests => scalar @tests;

foreach my $test (@tests) {
    my $html = $test->{html};

    my $html_obj = Mail::SpamAssassin::HTML->new(0, 0);
    $html_obj->parse($html);

    my $uris = $html_obj->{results}->{uri_detail};
    is_deeply($uris, $test->{uris}, "URI details match for HTML: $html");

}