Test::Mojo::DOM - DOM test
use Test::Mojo::DOM;
use Test::More tests => 35;
my $t = Test::Mojo::DOM->new(MyApp->new);
$t->get_ok('/')
->status_is(200)
->dom_inspector(sub {
my $t = shift;
$t->at('a')
->attr_is('href', '../')
->attr_isnt('href', './')
->attr_like('href', qr'\.\./')
->attr_unlike('href', qr'\.\./a')
->text_is('some link')
->text_isnt('some link2')
->text_like(qr'some')
->text_unlike(qr'some2')
->has_attr('href')
->has_attr_not('empty')
->has_attr_not('not_exists');
$t->at('a')->get(1)
->text_is('some link2');
$t->at('a:nth-child(2)')
->text_is('some link2');
$t->at('a')->each(sub {
my $t = shift;
$t->text_like(qr{.});
$t->text_unlike(qr{a});
$t->attr_like('href', qr{.});
$t->attr_unlike('href', qr{a});
});
$t->at('a')->parent->attr_is('id', 'some_p');
$t->at('a')->parent->parent->attr_is('id', 'wrapper');
$t->at('#some_p')->has_child('a');
$t->at('#some_p2')->has_child_not('a');
$t->at('#some_img')->has_class('class1');
$t->at('#some_img')->has_class('class2');
$t->at('#some_img')->has_class('class3');
$t->at('#some_img')->has_class_not('class4');
});This is a test tool for Mojo apps on DOM structure.
Test::Mojo::DOM inherits all attributes from Test::Mojo.
Test::Mojo::DOM inherits all methods from Test::Mojo and implements the following new ones.
$t->dom_inspector(sub {
my $inspector = shift;
});Sugama Keita, <sugama@jamadam.com>
Copyright (C) 2012 by Sugama Keita.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.