App-WRT
view release on metacpan or search on metacpan
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use open qw(:std :utf8);
use lib 'lib';
use Encode;
use JSON;
use Test::More tests => 19;
# Does the module load?
require_ok('App::WRT');
chdir 'example/blog';
# configuration
ok(
my $w = App::WRT::new_from_file('wrt.json'),
"got WRT object."
);
# individual subroutine tests
my $datestamp = $w->datestamp('2014/1/1/test_entry');
like(
$datestamp,
qr{test_entry},
'datestamp for a fragment references that fragment'
) or diag($datestamp);
# icon rendering
my $with_icon = $w->display('icon_test');
like(
$with_icon,
qr/img src/,
'icon_test has an image in it'
) or diag($with_icon);
my $icon_textfile = $w->icon_markup('icon_test/textfile', 'alt');
is(
$icon_textfile,
q{<img src="https://example.com/icon_test/textfile.icon.png"
width="48" height="58"
alt="alt" />},
'got expected icon for icon_test/textfile'
) or diag($icon_textfile);
my $icon_dir = $w->icon_markup('icon_test/dir', 'alt');
is(
$icon_dir,
q{<img src="https://example.com/icon_test/dir/index.icon.png"
width="48" height="58"
alt="alt" />},
'got expected icon for icon_test/dir'
) or diag($icon_dir);
my $icon_subentry = $w->icon_markup('icon_test/dir/subentry', 'alt');
is(
$icon_subentry,
q{<img src="https://example.com/icon_test/dir/subentry.icon.png"
width="48" height="58"
alt="alt" />},
'got expected icon for icon_test/dir/subentry'
) or diag($icon_subentry);
# feed rendering
my $with_stars = $w->display('2014/1/2');
like(
$with_stars,
qr/â¨/s,
'2014/1/2 contains some stars which we also expect to show up in the feed'
);
my $feed = $w->feed_print_recent();
like(
$feed,
qr/â¨/s,
'feed contains some stars'
) or diag($feed);
my $json_feed = $w->feed_print_json();
my $JSON = JSON->new->utf8->pretty;
my $feed_hashref = $JSON->decode(encode('UTF-8', $json_feed));
( run in 0.994 second using v1.01-cache-2.11-cpan-b16cb0d3907 )