File: node-types.t

package info (click to toggle)
libweb-query-perl 1.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 424 kB
  • sloc: perl: 984; xml: 329; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 689 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
use strict;
use warnings;

use Test2::V0;

use lib 't/lib';

use WQTest;

WQTest::test {
    my $class = shift;

    my $q = $class->new_from_html(<<'END');
        <html>
        <body>
        <x>
            one 
            <div><p>two</p></div>
            <!-- three -->
        </x>
        </body>
        </html>
END

        my $contents = $q->find('x')->contents;
        
        is $contents->find('p')->html => 'two', 'skip over text and comments';

        like $contents->filter(sub{ $_->tagname eq  '#text' })->as_html 
            => qr'one', '#text';

        like $contents->filter(sub{ $_->tagname eq  '#comment' })->as_html 
            => qr'three', '#comment';
}