Skip to content

Commit 1d72417

Browse files
committedJul 7, 2009
Test HTML::Form selectors
1 parent 5a3f584 commit 1d72417

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
 

‎MANIFEST

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ t/html/form.t Test HTML::Form module
9393
t/html/form-param.t More HTML::Form tests.
9494
t/html/form-multi-select.t More HTML::Form tests
9595
t/html/form-maxlength.t More HTML::Form tests
96+
t/html/form-selector.t More HTML::Form tests
9697
t/live/apache.t
9798
t/live/apache-listing.t Test File::Listing::apache package
9899
t/live/https.t

‎t/html/form-selector.t

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!perl -w
2+
3+
use strict;
4+
use Test qw(plan ok);
5+
6+
plan tests => 12;
7+
8+
use HTML::Form;
9+
10+
my $form = HTML::Form->parse(<<"EOT", base => "http://example.com", strict => 1);
11+
<form>
12+
<input name="n1" id="id1" class="A" value="1">
13+
<input id="id2" class="A" value="2">
14+
<input id="id3" class="B" value="3">
15+
<select id="id4">
16+
<option>1
17+
<option>2
18+
<option>3
19+
</selector>
20+
<input id="#foo" name="#bar" class=".D" disabled>
21+
</form>
22+
EOT
23+
24+
#$form->dump;
25+
26+
ok($form->value("n1"), 1);
27+
ok($form->value("^n1"), 1);
28+
ok($form->value("#id1"), 1);
29+
ok($form->value(".A"), 1);
30+
ok($form->value("#id2"), 2);
31+
ok($form->value(".B"), 3);
32+
33+
ok(j(map $_->value, $form->find_input(".A")), "1:2");
34+
35+
$form->find_input("#id2")->name("n2");
36+
$form->value("#id2", 22);
37+
ok($form->click->uri->query, "n1=1&n2=22");
38+
39+
# try some odd names
40+
ok($form->find_input("##foo")->name, "#bar");
41+
ok($form->find_input("#bar"), undef);
42+
ok($form->find_input("^#bar")->class, ".D");
43+
ok($form->find_input("..D")->id, "#foo");
44+
45+
sub j {
46+
join(":", @_);
47+
}

0 commit comments

Comments
 (0)
Please sign in to comment.