File: remove.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 (43 lines) | stat: -rw-r--r-- 785 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
use strict;
use warnings;

use Test2::V0;

use lib 't/lib';

use WQTest;

WQTest::test {
    my $class = shift;

    my $wq = $class->new_from_html( '<div><foo></foo></div>', { indent => "\t" } );
    $wq->find('foo')->remove;

    is $wq->as_html => '<div></div>';

    for my $method ( qw/ each map / ) {
        subtest $method => sub {
            plan tests => 5;

            my $wq = new_wq($class);

            $wq->find('p')->$method(sub{
                pass "deleting " . $_->text;
                $_->remove;
            });

            is $wq->find('p')->size => 0, "all deleted";
        };
    }
};

sub new_wq {
    shift->new(<<'END');
        <div>
            <p>one</p>
            <p>two</p>
            <p>three</p>
            <p>four</p>
        </div>
END
}