start of SubList filter code
[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');
ebd4c292 10 delete @{$s}{grep /^_/, keys %$s};
95148a72 11 is_deeply($s,
12 {
ebd4c292 13 created => '',
95148a72 14 title => '--TITLE--',
15 description => '--DESCRIPTION--',
16 keywords => '--KW1-- --KW2--'
17 },
18 'Metadata ok'
19 );
20}
21
22my $ps = SCSite::PageSet->new(base_dir => 't/pages');
23
24my $test_html = q{<html>
25 <head>
26 <title>--TITLE--</title>
27 <meta name="description" content="--DESCRIPTION--" />
28 <meta name="keywords" content="--KW1-- --KW2--" />
29 </head>
30 <body>
31 <p>Some markdown here.</p>
32 </body>
33</html>};
34
35check_structure($ps->_extract_from_html($test_html));
36
37my $test_md = q{Title: --TITLE--
38description: --DESCRIPTION--
39keywords: --KW1-- --KW2--
40
41Some markdown here.
42};
43
44check_structure($ps->_extract_from_md($test_md));
45
46check_structure($ps->get({ path => 'index' }));
47
48check_structure($ps->get({ path => 'one/two' }));
49
50done_testing;