|
|
|
|
|
|
|
|
|
var mime = require('../mime'); |
|
var assert = require('assert'); |
|
var path = require('path'); |
|
|
|
|
|
|
|
|
|
|
|
assert.equal('text/plain', mime.lookup('text.txt')); |
|
assert.equal('text/plain', mime.lookup('TEXT.TXT')); |
|
assert.equal('text/plain', mime.lookup('dir/text.txt')); |
|
assert.equal('text/plain', mime.lookup('.text.txt')); |
|
assert.equal('text/plain', mime.lookup('.txt')); |
|
assert.equal('text/plain', mime.lookup('txt')); |
|
assert.equal('text/plain', mime.lookup('/txt')); |
|
assert.equal('text/plain', mime.lookup('\\txt')); |
|
assert.equal('application/octet-stream', mime.lookup('text.nope')); |
|
assert.equal('fallback', mime.lookup('text.fallback', 'fallback')); |
|
|
|
|
|
|
|
|
|
|
|
assert.equal('txt', mime.extension(mime.types.text)); |
|
assert.equal('html', mime.extension(mime.types.htm)); |
|
assert.equal('bin', mime.extension('application/octet-stream')); |
|
assert.equal('bin', mime.extension('application/octet-stream ')); |
|
assert.equal('html', mime.extension(' text/html; charset=UTF-8')); |
|
assert.equal('html', mime.extension('text/html; charset=UTF-8 ')); |
|
assert.equal('html', mime.extension('text/html; charset=UTF-8')); |
|
assert.equal('html', mime.extension('text/html ; charset=UTF-8')); |
|
assert.equal('html', mime.extension('text/html;charset=UTF-8')); |
|
assert.equal('html', mime.extension('text/Html;charset=UTF-8')); |
|
assert.equal(undefined, mime.extension('unrecognized')); |
|
|
|
|
|
|
|
|
|
|
|
assert.equal('font/woff', mime.lookup('file.woff')); |
|
assert.equal('application/octet-stream', mime.lookup('file.buffer')); |
|
|
|
|
|
assert.equal('font/otf', mime.lookup('file.otf')); |
|
|
|
|
|
|
|
|
|
|
|
assert.equal('UTF-8', mime.charsets.lookup('text/plain')); |
|
assert.equal('UTF-8', mime.charsets.lookup(mime.types.js)); |
|
assert.equal('UTF-8', mime.charsets.lookup(mime.types.json)); |
|
assert.equal(undefined, mime.charsets.lookup(mime.types.bin)); |
|
assert.equal('fallback', mime.charsets.lookup('application/octet-stream', 'fallback')); |
|
|
|
console.log('\nAll tests passed'); |
|
|