| 1 | use strict; |
| 2 | use warnings; |
| 3 | use Test::More; |
| 4 | use HTML::TreeBuilder::LibXML; |
| 5 | use Data::Dumper; |
| 6 | |
| 7 | # list context |
| 8 | my $tree = HTML::TreeBuilder::LibXML->new_from_content('<header>foo</header><footer>bar</footer>'); |
| 9 | |
| 10 | my @nodes = $tree->disembowel; |
| 11 | is join('|', map {$_->as_HTML} @nodes), '<header>foo</header>|<footer>bar</footer>', 'disembowel - list context'; |
| 12 | |
| 13 | isa_ok $nodes[0]->parent->{node}, 'XML::LibXML::Document', 'first node parent'; |
| 14 | isa_ok $nodes[1]->parent->{node}, 'XML::LibXML::Document', 'second node parent'; |
| 15 | ok $nodes[0]->parent->{node}->isSameNode($nodes[1]->parent->{node}), 'nodes belong to the same document'; |
| 16 | |
| 17 | |
| 18 | # scalar context |
| 19 | $tree = HTML::TreeBuilder::LibXML->new_from_content('<header>foo</header><footer>bar</footer>'); |
| 20 | |
| 21 | my $node = $tree->disembowel; |
| 22 | is $node->as_HTML, '<div><header>foo</header><footer>bar</footer></div>', 'disembowel - scalar context'; |
| 23 | |
| 24 | isa_ok $node->parent->{node}, 'XML::LibXML::Document', 'node parent'; |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | done_testing; |