Skip to content

Commit

Permalink
Merge pull request #1 from kyzn/master
Browse files Browse the repository at this point in the history
Replace content_[un]like regexps with grep_inputs
  • Loading branch information
chizmw committed Oct 4, 2016
2 parents 3240520 + ddc3693 commit 79a5fd2
Showing 1 changed file with 8 additions and 56 deletions.
64 changes: 8 additions & 56 deletions t/00.basic.t
Expand Up @@ -13,66 +13,18 @@ my $mech = Test::WWW::Mechanize::Catalyst->new;
ok(defined $mech);

$mech->get_ok('http://localhost/form/first');
my @inputs = $mech->grep_inputs( { type => 'text', name => 'first_text' } );
is( scalar @inputs, 1, "form not re-filled");

$mech->content_like(
qr{
<input
\s+
name="first_text"
\s+
type="text"
\s*
/>
}xms,
q{form not re-filled}
);

$mech->content_unlike(
qr{
<input
\s+
value="foo"
\s+
name="first_text"
\s+
type="text"
\s*
/>
}xms,
q{form not re-filled}
);
@inputs = $mech->grep_inputs( { type => 'text', name => 'first_text', value => 'foo' } );
is( scalar @inputs, 0, "form not re-filled");

$mech->get_ok('http://localhost/form/first?first_text=foo');

$mech->content_like(
qr{
<input
\s+
value="foo"
\s+
name="first_text"
\s+
type="text"
\s*
/>
}xms,
q{form re-filled}
);
@inputs = $mech->grep_inputs( { type => 'text', name => 'first_text', value => 'foo' } );
is( scalar @inputs, 1, "form re-filled");

$mech->get_ok('http://localhost/form/first');
$mech->field('first_text', 'banana');
$mech->submit_form_ok(undef, q{submit filled form});
$mech->content_like(
qr{
<input
\s+
value="banana"
\s+
name="first_text"
\s+
type="text"
\s*
/>
}xms,
q{form re-filled}
);
@inputs = $mech->grep_inputs( { type => 'text', name => 'first_text', value => 'banana' } );
is( scalar @inputs, 1, "form re-filled");

0 comments on commit 79a5fd2

Please sign in to comment.