basic page rendering
[scpubgit/SCS.git] / t / pages.t
CommitLineData
95148a72 1use strictures 1;
2use Test::More;
3use SCSite::PageSet;
4
5sub check_structure {
6 my ($s) = @_;
7 $s = { %$s };
8 my $body = delete $s->{body};
9 like($body, qr/^\s+<p>Some markdown here.<\/p>\s+$/sm, 'Body correct');
10 is_deeply($s,
11 {
12 title => '--TITLE--',
13 description => '--DESCRIPTION--',
14 keywords => '--KW1-- --KW2--'
15 },
16 'Metadata ok'
17 );
18}
19
20my $ps = SCSite::PageSet->new(base_dir => 't/pages');
21
22my $test_html = q{<html>
23 <head>
24 <title>--TITLE--</title>
25 <meta name="description" content="--DESCRIPTION--" />
26 <meta name="keywords" content="--KW1-- --KW2--" />
27 </head>
28 <body>
29 <p>Some markdown here.</p>
30 </body>
31</html>};
32
33check_structure($ps->_extract_from_html($test_html));
34
35my $test_md = q{Title: --TITLE--
36description: --DESCRIPTION--
37keywords: --KW1-- --KW2--
38
39Some markdown here.
40};
41
42check_structure($ps->_extract_from_md($test_md));
43
44check_structure($ps->get({ path => 'index' }));
45
46check_structure($ps->get({ path => 'one/two' }));
47
48done_testing;