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