Commit | Line | Data |
95148a72 |
1 | use strictures 1; |
2 | use Test::More; |
3 | use SCSite::PageSet; |
fc436d2e |
4 | use IO::All; |
95148a72 |
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'); |
ebd4c292 |
11 | delete @{$s}{grep /^_/, keys %$s}; |
fc436d2e |
12 | delete $s->{path}; |
95148a72 |
13 | is_deeply($s, |
14 | { |
ebd4c292 |
15 | created => '', |
95148a72 |
16 | title => '--TITLE--', |
17 | description => '--DESCRIPTION--', |
18 | keywords => '--KW1-- --KW2--' |
19 | }, |
20 | 'Metadata ok' |
21 | ); |
22 | } |
23 | |
fc436d2e |
24 | my $ps = SCSite::PageSet->new(base_dir => io->dir('t/pages')); |
95148a72 |
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; |