### ----------------------------------------------------
### -- Collection
### -- Licenses: Artistic-2.0
### -- Authors: Richard Hainsworth, aka finanalyst
### -- File: xt/90-test-plugins/30-otherkey.rakutest
### ----------------------------------------------------
use v6.d;
use Test;
use Collection::TestPlugin;
use Test::Output;

plan 7;

constant DIR = 'xt/plugin-test-dir';

bail-out "{ DIR } must exist. Have check-file tests been run?"
    unless DIR.IO ~~ :e & :d;
$Collection::TestPlugin::TESTING = True;
chdir DIR;

ok Collection::TestPlugin::check-otherkey( %( :css<README.rakudoc>,) ), 'other keys, if they exist, should point to a filename';
nok Collection::TestPlugin::check-otherkey( %( :css(),) ), 'other keys, traps not pointing to a filename';
ok Collection::TestPlugin::check-otherkey( %( :css(), :information<css>) ), 'allow empty key if in information list';
ok Collection::TestPlugin::check-otherkey( %( :css("not a filename here"), :information<css>) ), 'dont check Str val of key if in information list';
ok Collection::TestPlugin::check-otherkey( %( :css<README.rakudoc custom.raku>,) ), 'other keys, if a list, should each be a filename';
ok Collection::TestPlugin::check-otherkey( %( :css( ['pop-search-bar.js',2], ),) ), 'skips a list of array';

$Collection::TestPlugin::TEST_OUT = True;
output-like { Collection::TestPlugin::check-otherkey( %( :css<README.rakudoc another.js>,) )},
        / 'another.js' /, 'traps wrong file';
done-testing;


