### ----------------------------------------------------
### -- Rakuast::RakuDoc::Render
### -- Licenses: Artistic-2.0
### -- Authors: Richard Hainsworth
### -- File: xt/080-item.rakutest
### ----------------------------------------------------
use v6.d;
use Test;
use RakuDoc::Render;

plan 4;

my $ast;
my $rv;
my RakuDoc::Processor $rdp .= new(:test);
$ast = Q:to/QAST/.AST;
    =begin rakudoc
    =head1 Item testing

    Some text
    =item first item should be level 1
    =item second item L1
    =item third item L1
    =end rakudoc
    QAST
$rv = $rdp.render( $ast, :pre-finalised );
like $rv.body.Str, / '<head>' .+ 'Item testing' .+ '</head>' /, 'head template good';
like $rv.body.Str, / '</head>' .+ '<item-list>'
    .+ '<item>' .+ 'contents: ｢first' .+ 'level: ｢1｣' .+ '</item>'
    .+ 'third' .+ '</item>' .+ '</item-list>'
    /, 'list seems OK';

$ast = Q:to/QAST/.AST;
    =begin rakudoc
    =head1 Item testing

    Some text
    =item first item should be level 1
    =item second item L1
    =item third item L1

    =head after list

    some more text
    =end rakudoc
    QAST

$rv = $rdp.render( $ast, :pre-finalised );
like $rv.body.Str, / '<head>' .+ 'Item testing' .+ '</head>' .+ '<item-list>'
    .+ '<item>' .+ 'contents: ｢first' .+ 'level: ｢1｣' .+ '</item>'
    .+ 'third' .+ '</item>' .+ '</item-list>'
    .+ 'head' .+ 'after list' .+ '</head>'
    .+ 'some more text'
    /, 'list before new block seems OK';

$ast = Q:to/QAST/.AST;
    =begin rakudoc

    Some text
    =item first item should be level 1
    =item second item L1
    =item third item L1

    End the item list with a paragraph.

    =end rakudoc
    QAST
$rv = $rdp.render( $ast, :pre-finalised );
like $rv.body.Str, /
    'Some text' .*
    '<item-list>' .+
    '<item>' .+ 'contents: ｢first' .+ 'level: ｢1｣' .+ '</item>'
        .+ 'third' .+ '</item>' .+ '</item-list>' .+
    'End the item list with a paragraph'
    /, 'list ends with paragraph';

done-testing;


