page loading code
[scpubgit/SCS.git] / t / pages.t
1 use strictures 1;
2 use Test::More;
3 use SCSite::PageSet;
4
5 sub 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
20 my $ps = SCSite::PageSet->new(base_dir => 't/pages');
21
22 my $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
33 check_structure($ps->_extract_from_html($test_html));
34
35 my $test_md = q{Title: --TITLE--
36 description: --DESCRIPTION--
37 keywords: --KW1-- --KW2--
38
39 Some markdown here.
40 };
41
42 check_structure($ps->_extract_from_md($test_md));
43
44 check_structure($ps->get({ path => 'index' }));
45
46 check_structure($ps->get({ path => 'one/two' }));
47
48 done_testing;