"Fossies" - the Fresh Open Source Software Archive

Member "MIME-Types-2.22/t/40mojo.t" (9 Dec 2020, 967 Bytes) of package /linux/privat/MIME-Types-2.22.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "40mojo.t": 2.17_vs_2.18.

    1 #!/usr/bin/env perl
    2 #
    3 # Test Mojo plugin
    4 #
    5 
    6 use strict;
    7 use warnings;
    8 
    9 use lib qw(lib t);
   10 use Test::More;
   11 
   12 eval "require Mojo::Base";
   13 plan skip_all => 'Mojo probably not installed' if $@;
   14 
   15 plan tests => 15;
   16 
   17 require_ok('MojoX::MIME::Types');
   18 
   19 my $m = MojoX::MIME::Types->new;
   20 isa_ok($m, 'MojoX::MIME::Types');
   21 isa_ok($m->mimeTypes, 'MIME::Types');
   22 
   23 my $t = $m->types;
   24 isa_ok($t, 'HASH', 'types table (deprecated)');
   25 cmp_ok(keys %$t, '>', 1000, 'MIME::Types describes '.(keys %$t).' extensions');
   26 ok(exists $t->{txt});
   27 isa_ok($t->{txt}, 'ARRAY');
   28 cmp_ok(@{$t->{txt}}, '==', 1);
   29 is($t->{txt}[0], 'text/plain');
   30 
   31 my $ext = $m->detect('text/html, application/json;q=9');
   32 isa_ok($ext, 'ARRAY', 'detect() reports '.@$ext);
   33 ok(grep $_ eq 'html', @$ext, 'contains html');
   34 ok(grep $_ eq 'json', @$ext, 'contains json');
   35 
   36 is($m->type('html'), 'text/html', 'type($ext)');
   37 
   38 is_deeply $m->detect('image/missing'), [], 'missing type';
   39 
   40 is($m->file_type('a/b/c.gif'), 'image/gif');