### ----------------------------------------------------
### -- MIME::Types
### -- Licenses: Artistic-2.0
### -- Authors: Timothy Totten, Sizhe Zhao, Cam Stuart
### -- File: t/mime.rakutest
### ----------------------------------------------------
use Test;

use MIME::Types;

plan 12;

my $mime-from-string            = MIME::Types.new;

isa-ok($mime-from-string        , MIME::Types    ,"the object via new(Str)      is-a '{$mime-from-string.^name}'");
is $mime-from-string.type('txt'), 'text/plain'   ,"get a simple type            - plain text";

my $mime-from-iopath            = MIME::Types.new: $?FILE.IO.parent.parent.add('resources').add('mime.types');

isa-ok($mime-from-iopath,         MIME::Types    ,"the object via new(IO::Path) is-a '{$mime-from-iopath.^name}'");
is $mime-from-string.type('md') ,'text/markdown' ,"get a simple type            - markdown";

my $mime-default                = MIME::Types.new;

isa-ok($mime-default            , MIME::Types     ,"the object via new()         is-a '{$mime-default.^name}'");
is $mime-default.type('txt')    , 'text/plain'    ,"get a simple type            - plain text";
is $mime-default.type('svg')    , 'image/svg+xml' ,"get a + type";

is $mime-default.type('foo')    , Nil             ,"get an invalid type";

my @known = $mime-default.extensions('application/vnd.ms-excel');
is @known[0], 'xls', 'get extensions, first';
is @known[1], 'xlb', 'get extensions, second';
is @known[2], 'xlt', 'get extensions, third';

dies-ok { MIME::Types.new("/non/existent/path") }, "bogus mime type file dies";

# vim: expandtab shiftwidth=4


