Initial commit
This commit is contained in:
commit
ec49fedc45
1288 files changed
+226749
No files matched your search
+62
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Usage: node test.js
|
||||
*/
|
||||
|
||||
var mime = require('./browserify-mime');
|
||||
var assert = require('assert');
|
||||
|
||||
function eq(a, b) {
|
||||
console.log('Test: ' + a + ' === ' + b);
|
||||
assert.strictEqual.apply(null, arguments);
|
||||
}
|
||||
|
||||
console.log(Object.keys(mime.extensions).length + ' types');
|
||||
console.log(Object.keys(mime.types).length + ' extensions\n');
|
||||
|
||||
//
|
||||
// Test mime lookups
|
||||
//
|
||||
|
||||
eq('text/plain', mime.lookup('text.txt'));
|
||||
eq('text/plain', mime.lookup('.text.txt'));
|
||||
eq('text/plain', mime.lookup('.txt'));
|
||||
eq('text/plain', mime.lookup('txt'));
|
||||
eq('application/octet-stream', mime.lookup('text.nope'));
|
||||
eq('fallback', mime.lookup('text.fallback', 'fallback'));
|
||||
eq('application/octet-stream', mime.lookup('constructor'));
|
||||
eq('text/plain', mime.lookup('TEXT.TXT'));
|
||||
eq('text/event-stream', mime.lookup('text/event-stream'));
|
||||
eq('application/x-web-app-manifest+json', mime.lookup('text.webapp'));
|
||||
|
||||
//
|
||||
// Test extensions
|
||||
//
|
||||
|
||||
eq('txt', mime.extension(mime.types.text));
|
||||
eq('html', mime.extension(mime.types.htm));
|
||||
eq('bin', mime.extension('application/octet-stream'));
|
||||
eq('bin', mime.extension('application/octet-stream '));
|
||||
eq('html', mime.extension(' text/html; charset=UTF-8'));
|
||||
eq('html', mime.extension('text/html; charset=UTF-8 '));
|
||||
eq('html', mime.extension('text/html; charset=UTF-8'));
|
||||
eq('html', mime.extension('text/html ; charset=UTF-8'));
|
||||
eq('html', mime.extension('text/html;charset=UTF-8'));
|
||||
eq('html', mime.extension('text/Html;charset=UTF-8'));
|
||||
eq(undefined, mime.extension('constructor'));
|
||||
|
||||
//
|
||||
// Test node types
|
||||
//
|
||||
|
||||
eq('application/octet-stream', mime.lookup('file.buffer'));
|
||||
eq('audio/mp4', mime.lookup('file.m4a'));
|
||||
|
||||
//
|
||||
// Test charsets
|
||||
//
|
||||
|
||||
eq('UTF-8', mime.charsets.lookup('text/plain'));
|
||||
eq(undefined, mime.charsets.lookup(mime.types.js));
|
||||
eq('fallback', mime.charsets.lookup('application/octet-stream', 'fallback'));
|
||||
|
||||
console.log('\nOK');
|
||||
Reference in new issue
Block a user