use v6.d;
use Test;
use Test::Deeply::Relaxed;

use RakuDoc::Render;

plan 6;

my $ast;
my $rv;
my RakuDoc::Processor $rdp .= new(:test);

is $rdp.output-format, 'txt', 'defaults to txt';
$ast = Q:to/QAST/.AST;
    =head1 Test text
    QAST

$rv = $rdp.render( $ast, :pre-finalised );

isa-ok $rv, RakuDoc::Processed, 'got a RakuDoc Processed object';
like $rv.body.Str, /
    '<head>' .+?
    'caption: ｢Test text｣' .+
    'contents: ｢Test text｣' .+
    'id: ｢｣' .+
    'level: ｢1｣' .+
    'numeration: ｢｣' .+
    'target: ｢Test_text｣' .+
    '</head>'
    /, 'head template works';
$ast = Q:to/QAST/.AST;
    =begin rakudoc :kind<sub> :subkind<operator> :category<Language>
    =head This is a header

    Some text in a paragraph
    =end rakudoc
    QAST
$rv = $rdp.render( $ast, :pre-finalised );
cmp-ok $rv.source-data<rakudoc-config>.keys,'(>=)', <kind subkind category>,
        'places rakudoc metadata correctly';
$ast = Q:to/QAST/.AST;
    =for head :id<Quick id>
    Second test text
    QAST
$rv = $rdp.render( $ast, :pre-finalised );
like $rv.body.Str, / '<head>' .+ 'level' .+ 1 .+ '</head>' /, 'plain head has level 1';
like $rv.body.Str, / '<head>' .+ 'id' .+ 'Quick id' .+ '</head>' /, 'head got id data';

done-testing;
