arrays.js 983 B

123456789101112131415161718192021222324252627282930313233
  1. var test = require('tape'),
  2. wildcard = require('../'),
  3. testdata = [
  4. 'a.b.c',
  5. 'a.b',
  6. 'a',
  7. 'a.b.d'
  8. ],
  9. testdataSep = [
  10. 'a:b:c',
  11. 'a:b',
  12. 'a',
  13. 'a:b:d'
  14. ];
  15. test('array result matching tests', function(t) {
  16. t.plan(5);
  17. t.equal(wildcard('*', testdata).length, 4, '* matches all testdata');
  18. t.equal(wildcard('a.*', testdata).length, 4, '4 matches found');
  19. t.equal(wildcard('a.b.*', testdata).length, 3, '3 matches found');
  20. t.equal(wildcard('a.*.c', testdata).length, 1);
  21. t.equal(wildcard('b.*.d', testdata).length, 0);
  22. });
  23. test('array result with separator matching tests', function(t) {
  24. t.plan(4);
  25. t.equal(wildcard('a:*', testdataSep, ':').length, 4, '4 matches found');
  26. t.equal(wildcard('a:b:*', testdataSep, ':').length, 3, '3 matches found');
  27. t.equal(wildcard('a:*:c', testdataSep, ':').length, 1);
  28. t.equal(wildcard('b:*:d', testdataSep, ':').length, 0);
  29. });