### ----------------------------------------------------
### -- Menu::Simple
### -- Licenses: Artistic-2.0
### -- Authors: Steve Dondley
### -- File: t/xt/00-AuthorTests.rakutest
### ----------------------------------------------------
use v6.d;
use lib '.';
use Test;
use Test::Output;
use Menu::HashToMenu;

%*ENV<AUTHOR_TESTING> ?? plan 3 !! plan 2;

my %hash = one => 'Option A', 'two' => 'blah', 'AAA' => {submenu1 => { subsubmenu => 1}, submenu2 => 'hello' };
is HashToMenu.new(%hash).WHAT, HashToMenu, 'class exists';

when !%*ENV<AUTHOR_TESTING> { skip 'Skipping author tests'; }

my $menu = HashToMenu.new(%hash);
say '';
lives-ok { $menu.execute }, 'executes menu';

my %hash2 = one => 'two';
my &action = sub ($str) { say $str };
my &processor = sub ($str) { flip $str };
my $menu2 = HashToMenu.new(%hash2, &action, &processor );
$menu2.menu[0].display;
output-like { $menu2.execute }, /.*? owt \n .*/, 'perorms action on value of selected menu item';

done-testing;


