a zip code crypto-currency system good for red ONLY

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * Usage: node test.js
  3. */
  4. var mime = require('../mime');
  5. var assert = require('assert');
  6. var path = require('path');
  7. //
  8. // Test mime lookups
  9. //
  10. assert.equal('text/plain', mime.lookup('text.txt')); // normal file
  11. assert.equal('text/plain', mime.lookup('TEXT.TXT')); // uppercase
  12. assert.equal('text/plain', mime.lookup('dir/text.txt')); // dir + file
  13. assert.equal('text/plain', mime.lookup('.text.txt')); // hidden file
  14. assert.equal('text/plain', mime.lookup('.txt')); // nameless
  15. assert.equal('text/plain', mime.lookup('txt')); // extension-only
  16. assert.equal('text/plain', mime.lookup('/txt')); // extension-less ()
  17. assert.equal('text/plain', mime.lookup('\\txt')); // Windows, extension-less
  18. assert.equal('application/octet-stream', mime.lookup('text.nope')); // unrecognized
  19. assert.equal('fallback', mime.lookup('text.fallback', 'fallback')); // alternate default
  20. //
  21. // Test extensions
  22. //
  23. assert.equal('txt', mime.extension(mime.types.text));
  24. assert.equal('html', mime.extension(mime.types.htm));
  25. assert.equal('bin', mime.extension('application/octet-stream'));
  26. assert.equal('bin', mime.extension('application/octet-stream '));
  27. assert.equal('html', mime.extension(' text/html; charset=UTF-8'));
  28. assert.equal('html', mime.extension('text/html; charset=UTF-8 '));
  29. assert.equal('html', mime.extension('text/html; charset=UTF-8'));
  30. assert.equal('html', mime.extension('text/html ; charset=UTF-8'));
  31. assert.equal('html', mime.extension('text/html;charset=UTF-8'));
  32. assert.equal('html', mime.extension('text/Html;charset=UTF-8'));
  33. assert.equal(undefined, mime.extension('unrecognized'));
  34. //
  35. // Test node.types lookups
  36. //
  37. assert.equal('application/font-woff', mime.lookup('file.woff'));
  38. assert.equal('application/octet-stream', mime.lookup('file.buffer'));
  39. // TODO: Uncomment once #157 is resolved
  40. // assert.equal('audio/mp4', mime.lookup('file.m4a'));
  41. assert.equal('font/otf', mime.lookup('file.otf'));
  42. //
  43. // Test charsets
  44. //
  45. assert.equal('UTF-8', mime.charsets.lookup('text/plain'));
  46. assert.equal('UTF-8', mime.charsets.lookup(mime.types.js));
  47. assert.equal('UTF-8', mime.charsets.lookup(mime.types.json));
  48. assert.equal(undefined, mime.charsets.lookup(mime.types.bin));
  49. assert.equal('fallback', mime.charsets.lookup('application/octet-stream', 'fallback'));
  50. console.log('\nAll tests passed');