Sha256: 6a8d5f01d58e4b088d002f3942396e60fb10b189519779739805d89c04ad6043

Contents?: true

Size: 1.93 KB

Versions: 22

Compression:

Stored size: 1.93 KB

Contents

/**
 * Requires the async_testing module
 *
 * Usage: node test.js
 */
var mime = require('./mime');
exports["test mime lookup"] = function(test) {
  // easy
  test.equal('text/plain', mime.lookup('text.txt'));

  // hidden file or multiple periods
  test.equal('text/plain', mime.lookup('.text.txt'));

  // just an extension
  test.equal('text/plain', mime.lookup('.txt'));

  // just an extension without a dot
  test.equal('text/plain', mime.lookup('txt'));

  // default
  test.equal('application/octet-stream', mime.lookup('text.nope'));

  // fallback
  test.equal('fallback', mime.lookup('text.fallback', 'fallback'));

  test.finish();
};

exports["test extension lookup"] = function(test) {
  // easy
  test.equal('txt', mime.extension(mime.types.text));
  test.equal('html', mime.extension(mime.types.htm));
  test.equal('bin', mime.extension('application/octet-stream'));

  test.finish();
};

exports["test mime lookup uppercase"] = function(test) {
  // easy
  test.equal('text/plain', mime.lookup('TEXT.TXT'));

  // just an extension
  test.equal('text/plain', mime.lookup('.TXT'));

  // just an extension without a dot
  test.equal('text/plain', mime.lookup('TXT'));

  // default
  test.equal('application/octet-stream', mime.lookup('TEXT.NOPE'));

  // fallback
  test.equal('fallback', mime.lookup('TEXT.FALLBACK', 'fallback'));

  test.finish();
};

exports["test custom types"] = function(test) {
  test.equal('application/octet-stream', mime.lookup('file.buffer'));
  test.equal('audio/mp4', mime.lookup('file.m4a'));

  test.finish();
};

exports["test charset lookup"] = function(test) {
  // easy
  test.equal('UTF-8', mime.charsets.lookup('text/plain'));

  // none
  test.ok(typeof mime.charsets.lookup(mime.types.js) == 'undefined');

  // fallback
  test.equal('fallback', mime.charsets.lookup('application/octet-stream', 'fallback'));

  test.finish();
};

if (module == require.main) {
  require('async_testing').run(__filename, process.ARGV);
}

Version data entries

22 entries across 22 versions & 4 rubygems

Version Path
blackboard-3.1.9 lib/site_template/node_modules/mime/test.js
vulcan-0.8.2 server/node_modules/express/node_modules/mime/test.js
vulcan-0.8.1 server/node_modules/express/node_modules/mime/test.js
iron_worker_ng-0.10.1 iron_worker_examples/binary/phantom-nodejs/node_modules/phantom/node_modules/express/node_modules/connect/node_modules/mime/test.js
vulcan-0.8.0 server/node_modules/express/node_modules/mime/test.js
vulcan-0.7.2 server/node_modules/express/node_modules/mime/test.js
vulcan-0.7.1 server/node_modules/express/node_modules/mime/test.js
vulcan-0.7.0 server/node_modules/express/node_modules/mime/test.js
vulcan-0.6.1 server/node_modules/express/node_modules/mime/test.js
vulcan-0.6.0 server/node_modules/express/node_modules/mime/test.js
vulcan-0.5.0 server/node_modules/express/node_modules/mime/test.js
vulcan-0.4.0 server/node_modules/express/node_modules/mime/test.js
vulcan-0.2.5 server/node_modules/express/node_modules/mime/test.js
vulcan-0.2.4 server/node_modules/express/node_modules/mime/test.js
vulcan-0.2.3 server/node_modules/express/node_modules/mime/test.js
vulcan-0.2.2 server/node_modules/express/node_modules/mime/test.js
vulcan-0.2.1 server/node_modules/express/node_modules/mime/test.js
vulcan-0.2.0 server/node_modules/express/node_modules/mime/test.js
vulcan-0.1.6 server/node_modules/express/node_modules/mime/test.js
vulcan-0.1.5 server/node_modules/express/node_modules/mime/test.js