### ----------------------------------------------------
### -- Template::Nest::Fast
### -- Licenses: ISC
### -- Authors: Andinus <andinus@nand.sh>
### -- File: t/04-template-extension.rakutest
### ----------------------------------------------------
use Test;
use Template::Nest::Fast;

plan 3;

my IO $output-dir = $*PROGRAM.IO.parent.add('output');
my IO $template-dir = $*PROGRAM.IO.parent.add('templates');

my $nest = Template::Nest::Fast.new: :$template-dir, :template-extension('');
my $nest-js = Template::Nest::Fast.new: :$template-dir, :template-extension('js');
my $nest-js-underscored = Template::Nest::Fast.new: :$template-dir, :template_ext('js');

my %simple-page = %(
    TEMPLATE => '00-simple-page.html',
    variable => 'Simple Variable',
    simple_component => %(
        TEMPLATE => '01-simple-component.html',
        variable => 'Simple Variable in Simple Component'
    )
);

# render test with template-extension as empty.
is(
    $nest.render(%simple-page),
    $output-dir.add('01-simple-page.html').slurp,
    "Simple template is rendered with template-extension as empty."
);

my %simple-page-js = %(
    TEMPLATE => '30-main',
    var => 'Simple Variable',
);
# render test with template-extension as js.
is(
    $nest-js.render(%simple-page-js),
    $output-dir.add('06-main-template-extension.js').slurp,
    "Simple template is rendered with template-extension as 'js'."
);

is(
    $nest-js-underscored.render(%simple-page-js),
    $nest-js.render(%simple-page-js),
    "Simple template is rendered with template-extension as 'js' and underscored option."
);


