3 use Test::More tests => 11;
6 use Support::TestSetup;
10 Support::TestSetup::login();
12 my $pr = SL::Presenter->get;
14 # Passing invalid parameters:
15 throws_ok { $pr->render(\'dummy', { unknown => 1 }) } qr/unsupported option/i, 'string ref, unknown parameter';
16 throws_ok { $pr->render(\'dummy', { type => "excel" }) } qr/unsupported type/i, 'string ref, unsupported "type"';
17 throws_ok { $pr->render({}) } qr/unsupported.*template.*reference.*type/i, 'string ref, unsupported template argument reference type';
18 throws_ok { $pr->render('does/not/exist') } qr/template.*file.*not.*found/i, 'non-existing template file name';
20 # Type of return value:
21 is(ref($pr->render(\'Hallo')), 'SL::Presenter::EscapedText', 'render returns SL::Presenter::EscapedText');
23 # Actual return value for string ref parameters (enforce stringification from SL::Presenter::EscapedText before comparison):
24 is("" . $pr->render(\'Hallo [% world %]', world => 'Welt'), 'Hallo Welt', 'render string ref, no args');
25 is("" . $pr->render(\'Hallo [% world %]', { process => 0 }, world => 'Welt'), 'Hallo [% world %]', 'render string ref, no processing');
26 is("" . $pr->render(\'Hallo [% world %]', { type => 'js' }, world => 'Welt'), 'Hallo Welt', 'render string ref, different type');
28 # Actual return value for template file name parameters (enforce stringification from SL::Presenter::EscapedText before comparison):
29 is("" . $pr->render('t/render', world => 'Welt'), "Hallo Welt\n", 'render template file, no args');
30 is("" . $pr->render('t/render', { process => 0 }, world => 'Welt'), "[\% USE HTML \%]Hallo [\% HTML.escape(world) \%]\n", 'render template file, no processing');
31 is("" . $pr->render('t/render', { type => 'js' }, thingy => 'jungle'), "Welcome to the jungle\n", 'render template file, different type');