Commit | Line | Data |
95148a72 |
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'); |
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 | |
22 | my $ps = SCSite::PageSet->new(base_dir => 't/pages'); |
23 | |
24 | my $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 | |
35 | check_structure($ps->_extract_from_html($test_html)); |
36 | |
37 | my $test_md = q{Title: --TITLE-- |
38 | description: --DESCRIPTION-- |
39 | keywords: --KW1-- --KW2-- |
40 | |
41 | Some markdown here. |
42 | }; |
43 | |
44 | check_structure($ps->_extract_from_md($test_md)); |
45 | |
46 | check_structure($ps->get({ path => 'index' })); |
47 | |
48 | check_structure($ps->get({ path => 'one/two' })); |
49 | |
50 | done_testing; |