Skip to content

Commit

Permalink
added some test cases for :scope, including a TODO test for siblings
Browse files Browse the repository at this point in the history
  • Loading branch information
jberger committed Aug 15, 2015
1 parent 59ff376 commit ca7d66e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions t/mojo/dom.t
Expand Up @@ -1218,6 +1218,33 @@ is $dom->at('#♥ ~ #☃ ~ *:nth-last-child(1)')->text, 'G', 'right text';
is $dom->at('#♥ + *:nth-last-child(2)')->text, 'F', 'right text';
is $dom->at('#♥ ~ *:nth-last-child(2)')->text, 'F', 'right text';

# Scoped selectors
$dom = Mojo::DOM::->new(<<EOF);
<div>
<p>One</p>
<p>Two</p>
<p><a href="#">Link</a></p>
</div>
<div>
<p>Three</p>
<p>Four</p>
</div>
EOF
is $dom->at('div')->at(':scope p')->text, 'One', 'right text';
is $dom->at('div')->at(':scope > p')->text, 'One', 'right text';
is $dom->at('div')->at('> p')->text, 'One', 'right text';
is $dom->at('div')->at(':scope a')->text, 'Link', 'right text';
ok !$dom->at('div')->at(':scope > a'), 'not a direct child';
is $dom->find('div')->last->at(':scope p')->text, 'Three', 'right text';
is $dom->find('div')->last->at(':scope > p')->text, 'Three', 'right text';
is $dom->find('div')->last->at('> p')->text, 'Three', 'right text';
TODO: {
local $TODO = 'sibling :scope selectors are a work in progress';
#is $dom->at('p')->at(':scope + p')->text, 'Two', 'right text';
ok $dom->at('p')->at(':scope + p'), 'right text';
}


# Adding nodes
$dom = Mojo::DOM->new(<<EOF);
<ul>
Expand Down

0 comments on commit ca7d66e

Please sign in to comment.