File: lacks_uncapped_inputs.t

package info (click to toggle)
libtest-www-mechanize-perl 1.60-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 380 kB
  • sloc: perl: 2,725; makefile: 4
file content (39 lines) | stat: -rw-r--r-- 1,183 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!perl -T

use strict;
use warnings;
use Test::More tests => 5;
use Test::Builder::Tester;

use URI::file;

use Test::WWW::Mechanize ();

my $mech = Test::WWW::Mechanize->new();
isa_ok( $mech,'Test::WWW::Mechanize' );

GOOD: {
    my $uri = URI::file->new_abs( 't/lacks_uncapped_inputs-good.html' )->as_string;
    $mech->get_ok( $uri ) or die;

    test_out( 'ok 1 - This should have no failures' );
    $mech->lacks_uncapped_inputs( 'This should have no failures' );
    test_test( 'Finds the lacks' );
}

BAD: {
    my $uri = URI::file->new_abs( 't/lacks_uncapped_inputs-bad.html' )->as_string;
    $mech->get_ok( $uri ) or die;

    test_out( 'not ok 1 - This should have three errors found' );
    test_fail( +6 );
    test_diag( q{foo has no maxlength attribute} );
    test_diag( q{quux has an invalid maxlength attribute of "dogs"} );
    test_diag( q{crunchy has an invalid maxlength attribute of "-1"} );
    test_diag( q{bingo has an invalid maxlength attribute of ""} );
    test_diag( q{bongo has an invalid maxlength attribute of "  "} );
    $mech->lacks_uncapped_inputs( 'This should have three errors found' );
    test_test( 'Detect uncapped' );
}

done_testing();