MojoMojo
view release on metacpan or search on metacpan
t/formatter_all_textile.t view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 32;
use HTTP::Request::Common;
use Test::Differences;
use FindBin '$Bin';
use lib "$Bin/../lib";
use Data::Dumper;
my $original_formatter; # used to save/restore the existing formatter set up in mojomojo.db
my $c; # the Catalyst object of this live server
my $test; # test description
my $content; # the markup content that is being rendered
my $got; # the rendered result
my $expected; # the expected rendered result
BEGIN {
$ENV{CATALYST_CONFIG} = 't/var/mojomojo.yml';
use_ok('MojoMojo::Formatter::Textile')
and note('Comprehensive/chained test of formatters, with the main formatter set to Textile');
use_ok('Catalyst::Test', 'MojoMojo');
}
END {
ok($c->pref(main_formatter => $original_formatter), 'restore original formatter');
}
(undef, $c) = ctx_request('/');
#warn Dumper $c->config;
ok($original_formatter = $c->pref('main_formatter'), 'save original formatter');
ok($c->pref(main_formatter => 'MojoMojo::Formatter::Textile'),
'set preferred formatter to Textile');
$content = '';
$got = get(POST '/.jsrpc/render', [ content => $content ]);
is($got, 'Please type something', 'empty body');
#----------------------------------------------------------------------------
$test = 'headings';
$content = <<'TEXTILE';
h1. Welcome to MojoMojo!
This is your front page. Create
a [[New Page]] or edit this one
through the edit link at the bottom.
h2. Need some assistance?
Check out our [[Help]] section.
TEXTILE
$got = get(POST '/.jsrpc/render', [ content => $content ]);
eq_or_diff($got, <<'HTML', $test);
<h1>Welcome to MojoMojo!</h1>
<p>This is your front page. Create<br />
a <span class="newWikiWord"><a title="Not found. Click to create this page." href="/New_Page.edit">New Page?</a></span> or edit this one<br />
through the edit link at the bottom.</p>
<h2>Need some assistance?</h2>
<p>Check out our <a class="existingWikiWord" href="/help">Help</a> section.</p>
HTML
( run in 0.945 second using v1.01-cache-2.11-cpan-fe3c2283af0 )