fixup todo-forms.t and rename to forms.t (now works)
[catagits/HTML-Zoom.git] / t / forms.t
CommitLineData
23ba49c7 1use HTML::Zoom;
2use Test::More;
3
4my $zoom = HTML::Zoom->from_html(<<HTML);
5<form class="myform" action="/somewhere">
6<label />
7<input />
8</form>
9HTML
10
11my @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
16my $h = $zoom->select('.myform')->repeat_content([
17 map { my $field = $_; sub {
18 $_->select('label')
2daa653a 19 ->add_to_attribute( for => $field->{id} )
23ba49c7 20 ->then
21 ->replace_content( $field->{label} )
22 ->select('input')
2daa653a 23 ->add_to_attribute( name => $field->{name} )
23ba49c7 24 ->then
2daa653a 25 ->add_to_attribute( type => $field->{type} )
23ba49c7 26 ->then
2daa653a 27 ->add_to_attribute( value => $field->{value} )
23ba49c7 28 } } @fields
29 ])->to_html;
30
1f7b45ed 31is($h, q{<form class="myform" action="/somewhere">
32<label for="foo">foo</label>
33<input name="foo" type="text" value="0" />
34
35<label for="bar">bar</label>
36<input name="bar" type="radio" value="1" />
37</form>
38}, 'render all ok');
a88c1c57 39
23ba49c7 40done_testing;