File: 01_basic.t

package info (click to toggle)
libplack-middleware-debug-perl 0.16%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 308 kB
  • ctags: 51
  • sloc: perl: 594; sh: 54; makefile: 6; sql: 5
file content (32 lines) | stat: -rwxr-xr-x 873 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
#!/usr/bin/env perl
use warnings;
use strict;
use Plack::Test;
use Plack::Builder;
use HTTP::Request::Common;
use Test::More;
my @content_types = ('text/html', 'text/html; charset=utf8',);
for my $content_type (@content_types) {
    note "Content-Type: $content_type";
    my $app = sub {
        return [
            200, [ 'Content-Type' => $content_type ],
            ['<body>Hello World</body>']
        ];
    };
    $app = builder {
        enable 'Debug';
        $app;
    };
    test_psgi $app, sub {
        my $cb  = shift;
        my $res = $cb->(GET '/');
        is $res->code, 200, 'response status 200';
        for my $panel (qw(Environment Response Timer Memory)) {
            like $res->content,
              qr/<a href="#" title="$panel" class="plDebug${panel}\d+Panel">/,
              "HTML contains $panel panel";
        }
    };
}
done_testing;