make then() work on streams and fix up replace_content on in_place_close elements
[catagits/HTML-Zoom.git] / t / todo-forms.t
1 use HTML::Zoom;
2 use Test::More;
3
4 my $zoom = HTML::Zoom->from_html(<<HTML);
5 <form class="myform" action="/somewhere">
6 <label />
7 <input />
8 </form>
9 HTML
10
11 my @fields = (
12     { id => "foo", label => "foo", name => "foo", type => "text", value => 0 },
13     { id => "bar", label => "bar", name => "bar", type => "radio", value => 1 },
14 );
15
16 my $h = $zoom->select('.myform')->repeat_content([
17     map { my $field = $_; sub {
18               $_->select('label')
19                ->add_attribute( for => $field->{id} )
20                ->then
21                ->replace_content( $field->{label} )
22                ->select('input')
23                ->add_attribute( name => $field->{name} )
24                ->then
25                ->add_attribute( type => $field->{type} )
26                ->then
27                ->add_attribute( value => $field->{value} )
28            } } @fields
29        ])->to_html;
30
31 warn $h;
32
33 ok 1;
34 done_testing;