XXX: row method
[perl/html-form-simple.git] / t / html.t
index 166ab111149cfd8bc160ad17571b7284084b4e4e..08f0e6ba8d9e9c4320366ff3ced51cfd86995317 100644 (file)
--- a/t/html.t
+++ b/t/html.t
@@ -5,13 +5,39 @@ use warnings;
 
 use Test::More;
 
-plan tests => 68;
+plan tests => 80;
 
 use_ok('HTML::Form::Simple');
 
 my $form = HTML::Form::Simple->new;
 ok($form, 'new form');
 
+# basics
+
+is(
+       $form->quote('<"test">'),
+       '&lt;&quot;test&quot;>',
+       'quote'
+);
+
+is(
+       $form->quote(\'<"test">'),
+       '<"test">',
+       'quote unquoted'
+);
+
+is(
+       $form->tag('foo'),
+       '<foo>',
+       'tag'
+);
+
+is(
+       $form->tag('a "' => {'b"' => 'c"'}),
+       '<a " b"="c&quot;">',
+       'tag attributes'
+);
+
 # form
 
 is(
@@ -346,6 +372,15 @@ is_deeply(
        'multiple radio labels'
 );
 
+is_deeply(
+       [ $form->radio(undef, [0, 1], undef, 0) ],
+       [
+               '<input checked type="radio" value="0">',
+               '<input type="radio" value="1">',
+       ],
+       'radio default'
+);
+
 is_deeply(
        [ $form->radio(foo => ['foo', ''], 'test', {value => '', id => ''}) ],
        [
@@ -463,7 +498,7 @@ is_deeply(
        [ $form->check(foo => ['bar', {name => 'bar'}], {name => 'ignored'}) ],
        [
                '<label><input id="foo_1" name="foo" type="checkbox" value="1"> bar</label>',
-               '<input id="bar_2" name="bar" type="checkbox" value="2">',
+               '<input id="foo_2" name="bar" type="checkbox" value="2">',
        ],
        'checkbox names'
 );
@@ -508,6 +543,32 @@ is_deeply(
        'various checkboxes'
 );
 
+# row
+
+is(
+       $form->row(undef),
+       '<label></label> <input type="text">',
+       'empty row'
+);
+
+is(
+       $form->row('test'),
+       '<label for="test">test</label> <input id="test" name="test" type="text">',
+       'standard row'
+);
+
+is(
+       $form->row('test', {type => 'password'}, {for => '', label => '"blah"'}),
+       '<label>&quot;blah&quot;</label> <input id="test" name="test" type="password">',
+       'row options'
+);
+
+is(
+       $form->row('test', '"scalar"', {for => ''}),
+       '<label>test</label> &quot;scalar&quot;',
+       'row scalar'
+);
+
 # defaults
 
 my $defform = HTML::Form::Simple->new({foo => '<">', '' => 'empty', 0 => 0});