Skip to content

Commit

Permalink
added tests for all MIME types
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 26, 2012
1 parent df29eb8 commit ad748a1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -3,6 +3,7 @@ This file documents the revision history for Perl extension Mojolicious.
2.47 2012-01-26 00:00:00
- Added pdf MIME type. (bfaist)
- Improved documentation.
- Improved tests.

2.46 2012-01-25 00:00:00
- Added EXPERIMENTAL request_timeout attribute to Mojo::UserAgent.
Expand Down
30 changes: 24 additions & 6 deletions t/mojolicious/types.t
@@ -1,6 +1,6 @@
use Mojo::Base -strict;

use Test::More tests => 13;
use Test::More tests => 29;

# "Your mistletoe is no match for my *tow* missile."
use_ok 'Mojolicious::Types';
Expand All @@ -12,13 +12,31 @@ is $t->type('foo'), undef, 'no type';
$t->type(foo => 'foo/bar');
is $t->type('foo'), 'foo/bar', 'right type';

# Detection
is_deeply $t->detect('text/html'), ['htm', 'html'], 'right formats';
# Detect common MIME types
is_deeply $t->detect('application/atom+xml'), ['atom'], 'right formats';
is_deeply $t->detect('application/octet-stream'), ['bin'], 'right formats';
is_deeply $t->detect('text/css'), ['css'], 'right formats';
is_deeply $t->detect('image/gif'), ['gif'], 'right formats';
is_deeply $t->detect('application/gzip'), ['gz'], 'right formats';
is_deeply $t->detect('text/html'), ['htm', 'html'], 'right formats';
is_deeply $t->detect('image/x-icon'), ['ico'], 'right formats';
is_deeply $t->detect('image/jpeg'), ['jpeg', 'jpg'], 'right formats';
is_deeply $t->detect('application/x-javascript'), ['js'], 'right formats';
is_deeply $t->detect('application/json'), ['json'], 'right formats';
is_deeply $t->detect('audio/mpeg'), ['mp3'], 'right formats';
is_deeply $t->detect('application/pdf'), ['pdf'], 'right formats';
is_deeply $t->detect('image/png'), ['png'], 'right formats';
is_deeply $t->detect('application/rss+xml'), ['rss'], 'right formats';
is_deeply $t->detect('image/svg+xml'), ['svg'], 'right formats';
is_deeply $t->detect('application/x-tar'), ['tar'], 'right formats';
is_deeply $t->detect('text/plain'), ['txt'], 'right formats';
is_deeply $t->detect('application/x-font-woff'), ['woff'], 'right formats';
is_deeply $t->detect('text/xml'), ['xml', 'xsl'], 'right formats';
is_deeply $t->detect('application/zip'), ['zip'], 'right format';

# Detect special cases
is_deeply $t->detect('text/html;q=0.9'), ['htm', 'html'], 'right formats';
is_deeply $t->detect('text/html,*/*'), [], 'no formats';
is_deeply $t->detect('text/html;q=0.9,*/*'), [], 'no formats';
is_deeply $t->detect('text/html,*/*;q=0.9'), [], 'no formats';
is_deeply $t->detect('text/html;q=0.8,*/*;q=0.9'), [], 'no formats';
is_deeply $t->detect('application/octet-stream'), ['bin'], 'right formats';
is_deeply $t->detect('application/x-font-woff'), ['woff'], 'right formats';
is_deeply $t->detect('application/atom+xml'), ['atom'], 'right formats';

0 comments on commit ad748a1

Please sign in to comment.