X-Git-Url: http://git.shiar.net/perl/html-form-simple.git/blobdiff_plain/be81b5d559a8ed87ee6493f27b698343fada60c4..cb6c92feb70f4246804078114bb8ef37874ab1cd:/t/html.t diff --git a/t/html.t b/t/html.t index d12d6ef..c646cdb 100644 --- a/t/html.t +++ b/t/html.t @@ -5,7 +5,7 @@ use warnings; use Test::More; -plan tests => 43; +plan tests => 50; use_ok('HTML::Form::Simple'); @@ -119,15 +119,22 @@ is( ); is( - $form->input('', '', {disabled => 0, something => undef, class => undef, style => ''}), + $form->input('', '', { + disabled => 0, + something => undef, + class => undef, + style => '', + name => 'ignore', + value => 'overrides', + }), '', 'input with empty attributes' ); is( - $form->input(undef, undef, {name => 'override', value => 'override'}), - '', - 'ignore input overrides' + $form->input(undef, undef, {name => '0', value => '0'}), + '', + 'input overrides' ); is( @@ -269,17 +276,53 @@ is_deeply( ); is( - $form->radio(foo => 1), - '', + $form->radio(foo => 'test'), + '', 'radio method' ); +is( + $form->radio(foo => undef, [2]), #TODO + '', + 'labelless radio' +); + is( $form->radio(undef, {checked => 1}), '', 'simple radio button' ); +is_deeply( + [ $form->radio(undef, ['', '<">']) ], + [ + '', + '', + ], + 'multiple radios' +); + +is_deeply( + [ $form->radio(foo => 'test', ['foo', ''], {value => '', id => ''}) ], + [ + '', + '', + ], + 'multiple radios with custom value' +); + +is_deeply( + [ $form->radio(foo => ['', 0], [0, 1, '']) ], + [ + '', + '', + '', + ], + 'multiple radios with custom values' +); + +# check + is( $form->check('foo'), '', @@ -287,28 +330,50 @@ is( ); is( - $form->check(foo => 'test', {value => undef}), - '', - 'check parameters' + $form->check(foo => '<">'), + '', + 'labeled checkbox' ); is( - $form->check(undef, '', 1), - '', - 'simple checkbox' + $form->check(foo => {label => 'test', value => undef}, {disabled => 1}), + '', + 'check parameters' +); + +is_deeply( + [ $form->check(undef, '', 1) ], + [ '' ], + 'anonymous checkbox' ); -TODO: { - local $TODO = 'shorthand'; is_deeply( [ $form->check(undef, ['', '<">']) ], [ - '', - '', + '', + '', ], 'multiple checkboxes' ); -}; + +is_deeply( + [ $form->check(undef, [{}, undef], 1) ], + [ + '', + '', + ], + 'multiple checked checkboxes' +); + +is_deeply( + [ $form->check(undef, [{value => 4, type => 'radio'}], [1, 0, 0], {value => 3}) ], + [ + '', + '', + '', + ], + 'various checkboxes' +); #TODO