Skip to content

Commit

Permalink
better documentation browser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 27, 2015
1 parent 893d669 commit 2531199
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

6.34 2015-11-26
6.34 2015-11-27
- Fixed bug in Mojo::DOM where the wrap method would attempt to wrap an
HTML/XML fragment around the content of root nodes.
- Fixed bug in Mojo::DOM where the wrap_content method would attempt to wrap
Expand Down
21 changes: 21 additions & 0 deletions t/mojolicious/lib/MojoliciousPODTest.pm
@@ -0,0 +1,21 @@
package MojoliciousPODTest;

1;

=head1 One
PODTest
=head2 Two
my $foo = 'bar';
=head3 Three
Hello
=head4 Four
World!
=cut
72 changes: 33 additions & 39 deletions t/mojolicious/pod_renderer_lite_app.t
Expand Up @@ -3,6 +3,10 @@ use Mojo::Base -strict;
BEGIN { $ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll' }

use Test::More;

use FindBin;
use lib "$FindBin::Bin/lib";

use Mojolicious::Lite;
use Test::Mojo;

Expand Down Expand Up @@ -51,48 +55,38 @@ $t->get_ok('/art')->status_is(200)->text_like('h2[id="art"]' => qr/art/)
# Empty
$t->get_ok('/empty')->status_is(200)->content_is('');

# Perldoc browser (Welcome)
# Welcome
$t->get_ok('/perldoc')->status_is(200)->element_exists('#mojobar')
->text_is('#TUTORIAL a:nth-of-type(2)', 'TUTORIAL')
->text_is('#GUIDES a:nth-of-type(2)', 'GUIDES')
->content_like(qr/Mojolicious guide to the galaxy/);

# Perldoc browser (Welcome with slash)
$t->get_ok('/perldoc/')->status_is(200)
->text_is('#TUTORIAL a:nth-of-type(2)', 'TUTORIAL')
->text_is('#GUIDES a:nth-of-type(2)', 'GUIDES')
->content_like(qr/Mojolicious guide to the galaxy/)
->content_unlike(qr/Pirates/);

# Perldoc browser (Mojo documentation)
$t->get_ok('/perldoc/Mojo')->status_is(200)
->text_is('h1#SYNOPSIS a:nth-of-type(2)', 'SYNOPSIS')
->text_is('#handler a:nth-of-type(2)', 'handler')
->text_like('p', qr/Duct tape for the HTML5 web!/);

# Perldoc browser (Mojo documentation with format)
$t->get_ok('/perldoc/Mojo.html')->status_is(200)
->text_is('h1#SYNOPSIS a:nth-of-type(2)', 'SYNOPSIS')
->text_is('#handler a:nth-of-type(2)', 'handler')
->text_like('p', qr/Duct tape for the HTML5 web!/);

# Perldoc browser (negotiated Mojo documentation)
$t->get_ok('/perldoc/Mojo' => {Accept => 'text/html'})->status_is(200)
->text_is('h1#SYNOPSIS a:nth-of-type(2)', 'SYNOPSIS')
->text_is('#handler a:nth-of-type(2)', 'handler')
->text_like('p', qr/Duct tape for the HTML5 web!/);

# Perldoc browser (Mojo source with format)
$t->get_ok('/perldoc/Mojo.txt')->status_is(200)
->content_type_is('text/plain;charset=UTF-8')
->content_like(qr/package Mojo;/);

# Perldoc browser (negotiated Mojolicious source again)
$t->get_ok('/perldoc/Mojolicious' => {Accept => 'text/plain'})->status_is(200)
->content_type_is('text/plain;charset=UTF-8')->content_like(qr/\$VERSION/);
->text_like('title', qr/Mojolicious guide to the galaxy/);

# Headings
$t->get_ok('/perldoc/MojoliciousPODTest')->status_is(200)
->element_exists('h1#One')->element_exists('h2#Two')
->element_exists('h3#Three')->element_exists('h4#Four')
->element_exists('a[href=#One]')->element_exists('a[href=#Two]')
->element_exists('a[href=#Three]')->element_exists('a[href=#Four]')
->text_like('pre code', qr/\$foo/);

# Trailing slash
$t->get_ok('/perldoc/MojoliciousPODTest/')->element_exists('#mojobar')
->text_like('title', qr/PODTest/);

# Format
$t->get_ok('/perldoc/MojoliciousPODTest.html')->element_exists('#mojobar')
->text_like('title', qr/PODTest/);

# Format (source)
$t->get_ok('/perldoc/MojoliciousPODTest' => {Accept => 'text/plain'})
->status_is(200)->content_type_is('text/plain;charset=UTF-8')
->content_like(qr/package MojoliciousPODTest/);

# Negotiated source
$t->get_ok('/perldoc/MojoliciousPODTest' => {Accept => 'text/plain'})
->status_is(200)->content_type_is('text/plain;charset=UTF-8')
->content_like(qr/package MojoliciousPODTest/);

# Perldoc browser (unsupported format)
$t->get_ok('/perldoc/Mojolicious.json')->status_is(204);
$t->get_ok('/perldoc/MojoliciousPODTest.json')->status_is(204);

done_testing();

Expand Down

0 comments on commit 2531199

Please sign in to comment.