test.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. var test = require('tape');
  2. var match = require('./');
  3. test('image/jpeg matches image/jpeg', function(t) {
  4. t.plan(1);
  5. t.ok(match('image/jpeg', 'image/jpeg'));
  6. });
  7. test('image/jpeg matches image/*', function(t) {
  8. t.plan(1);
  9. t.ok(match('image/jpeg', 'image/*'));
  10. });
  11. test('image/jpeg does not match application/pdf', function(t) {
  12. t.plan(1);
  13. t.notOk(match('image/jpeg', 'application/pdf'));
  14. });
  15. test('image/jpeg does not match application/*', function(t) {
  16. t.plan(1);
  17. t.notOk(match('image/jpeg', 'application/*'));
  18. });
  19. test('can filter out a match from an array of patterns', function(t) {
  20. t.plan(1);
  21. t.deepEquals(
  22. ['application/*', 'image/*'].filter(match('image/jpeg')),
  23. ['image/*']
  24. );
  25. });
  26. test('can use wildcards with suffix definitions', function(t) {
  27. t.plan(1);
  28. t.ok(match('application/atom+xml', 'application/*+xml'));
  29. });
  30. test('can use wildcards with vendor part', function(t) {
  31. t.plan(1);
  32. t.ok(match('audio/vnd.rn-realaudio', 'audio/vnd.*'));
  33. });
  34. test('charset suffix is ignored', function(t) {
  35. t.plan(1);
  36. t.ok(match('application/json', 'application/json; charset=utf-8'));
  37. });