### ----------------------------------------------------
### -- Rakuast::RakuDoc::Render
### -- Licenses: Artistic-2.0
### -- Authors: Richard Hainsworth
### -- File: xt/500-To-MarkDown.rakutest
### ----------------------------------------------------
use v6.d;
use Test;
use Test::Run :runs_ok;

plan 4;

use RakuDoc::Render;
use RakuDoc::To::Markdown;
my @generic = RakuDoc::Processor.new.default-text-templates.keys.sort;
my @markdown = RakuDoc::To::Markdown.new.markdown-templates.keys.sort;

ok @generic (<=) @markdown, 'markdown redefines all the keys in generic';
%*ENV<RAKUDO_RAKUAST> = 1;
my @args = <<$*EXECUTABLE -I. --rakudoc=Markdown xt/test-files/test.rakudoc>>;
runs_ok(
    'simple markdown is generated',
    :@args,
    :out( /^ \s* '# Just a test' / )
);
%*ENV<MORE_MARKDOWN> = 'xt/test-filles/example.raku';
runs_ok(
    :@args,
    :exitcode(1),
    :err(/ 'filles' .+ 'not a file' /),
    'Bad file error'
);
%*ENV<MORE_MARKDOWN> = 'xt/test-files/markdown-example.raku';

runs_ok(
    :@args,
    :exitcode(0),
    :out(/^ \s* '# A Customisation message' / ),
    'new text is the first string'
);

done-testing;


