### ----------------------------------------------------
### -- Rakuast::RakuDoc::Render
### -- Licenses: Artistic-2.0
### -- Authors: Richard Hainsworth
### -- File: xt/060-simple-render.rakutest
### ----------------------------------------------------
use v6.d;
use Test;
use Test::Deeply::Relaxed;

use RakuDoc::Render;

plan 7;

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｣' .+
    'toc: ｢True｣' .+
    '</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 );
is-deeply-relaxed $rv.source-data<rakudoc-config>, %(:kind<sub>, :subkind<operator>, :category<Language>),
        'places rakudoc metadata correctly';
$ast = Q:to/QAST/.AST;
    =for head :!toc :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>' .+ 'toc' .+ 'False' .+ '</head>' /, 'head got toc data';
like $rv.body.Str, / '<head>' .+ 'id' .+ 'Quick id' .+ '</head>' /, 'head got id data';

done-testing;


