File: 00-markdown.t

package info (click to toggle)
libmarkdown-render-perl 1.60.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 228 kB
  • sloc: perl: 498; makefile: 6
file content (86 lines) | stat: -rw-r--r-- 1,910 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env perl

use strict;
use warnings;

use lib qw{$Bin/..};
use FindBin qw($Bin);

use Data::Dumper;
use English qw{-no_match_vars};
use Test::More;

our %TESTS = (
    new             => 'Markdown::Render->new',
    render_markdown => 'render HTML from markdown file',
);

########################################################################

plan tests => 1 + keys %TESTS;

# Find the test input file.
my $test_file;
for ('files', '..') {
    my $file = "$Bin/$_/README.md.in";
    if (-f $file) {
        $test_file = $file;
        last;
    }
}

BAIL_OUT("Unable to find test file")
    unless defined $test_file;

use_ok('Markdown::Render');

########################################################################
subtest 'new' => sub {
########################################################################
  my $md = eval {
    Markdown::Render->new(
      infile => $test_file,
      engine => 'text_markdown',
    );
  };

  ok( !$EVAL_ERROR, 'new' )
    or do {
    diag( Dumper( [$EVAL_ERROR] ) );
    BAIL_OUT('could not instantiate Markdown::Render');
    };
};

########################################################################
subtest 'render_markdown' => sub {
########################################################################
  my $md = eval {
    Markdown::Render->new(
      infile => $test_file,
      engine => 'text_markdown',
    );
  };

  ok( !$EVAL_ERROR, 'new(infile => file)' )
    or do {
    diag( Dumper( [$EVAL_ERROR] ) );
    BAIL_OUT('could not instantiate Markdown::Render');
    };

  ok( $md->get_markdown, 'read markdown file' );
  ok( !$md->get_html,    'no html yet' );

  isa_ok( $md->render_markdown, 'Markdown::Render' );

  ok( $md->get_html, 'render HTML' );

  ok( $md->render_markdown->get_html, 'retrieve HTML' );

  ok( $md->finalize_markdown->render_markdown->get_html,
    'finalize and render' );
};

1;

__DATA__
END_OF_PLAN