diff options
author | Julien Fiegehenn <simbabque@cpan.org> | 2022-07-04 22:16:11 +0100 |
---|---|---|
committer | Olaf Alders <olaf@wundersolutions.com> | 2022-07-04 22:19:12 -0400 |
commit | 15fdf99d52e87d8382000577612076eb7d95f504 (patch) | |
tree | 5ede4c75b93a90c2b8311941f6b48785ffd3b18b | |
parent | 59336ecb014d674ba86029929c59fe88a0ad8e2d (diff) |
add tests for tick() with no value
-rw-r--r-- | Changes | 3 | ||||
-rw-r--r-- | lib/WWW/Mechanize.pm | 5 | ||||
-rw-r--r-- | t/tick.html | 5 | ||||
-rw-r--r-- | t/tick.t | 6 |
4 files changed, 16 insertions, 3 deletions
@@ -1,6 +1,9 @@ Revision history for WWW::Mechanize {{$NEXT}} + [FIXED] + - tick() can now handle checkboxes without a value (GH#331) (Jordan M Adler + and Julien Fiegehenn) 2.10 2022-07-04 21:06:13Z diff --git a/lib/WWW/Mechanize.pm b/lib/WWW/Mechanize.pm index ee24ece..79c413a 100644 --- a/lib/WWW/Mechanize.pm +++ b/lib/WWW/Mechanize.pm @@ -2076,6 +2076,11 @@ as the third optional argument will cause the checkbox to be unticked. The third value does not need to be set if you wish to merely tick the box. + $mech->tick('extra', 'cheese'); + $mech->tick('extra', 'mushrooms'); + + $mech->tick('no_value', ''); # <input type="checkbox" name="no_value"> + =cut sub tick { diff --git a/t/tick.html b/t/tick.html index 88256a5..27e1a16 100644 --- a/t/tick.html +++ b/t/tick.html @@ -4,9 +4,12 @@ <input type="checkbox" name="foo" value="hello" /> Hello<br /> <input type="checkbox" name="foo" value="bye" /> Bye<br /> -<input type="checkbox" name="foo" value="arse" /> Arse<br /> +<input type="checkbox" name="foo" value="parse" /> Parse<br /> <input type="checkbox" name="foo" value="wibble" /> Wibble<br /> <input type="checkbox" name="foo" value="foo" /> Foo<br /> +<label> + <input type="checkbox" name="no_value" /> I have no value +</label> <input type="Submit" name="submit" value="Submit" label="Submit" /> </form> @@ -22,6 +22,8 @@ $mech->tick('foo','hello'); $mech->tick('foo','bye'); $mech->untick('foo','hello'); +$mech->tick('no_value', ''); + my $form = $mech->form_number(1); isa_ok( $form, 'HTML::Form' ); @@ -29,10 +31,10 @@ my $reqstring = $form->click->as_string; my $wanted = <<'EOT'; POST http://localhost/ -Content-Length: 21 +Content-Length: 31 Content-Type: application/x-www-form-urlencoded -foo=bye&submit=Submit +foo=bye&no_value=&submit=Submit EOT is( $reqstring, $wanted, 'Proper posting' ); |