UNPKG

909 BJavaScriptView Raw
1var 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
16test('array result matching tests', function(t) {
17 t.plan(4);
18
19 t.equal(wildcard('a.*', testdata).length, 4, '4 matches found');
20 t.equal(wildcard('a.b.*', testdata).length, 3, '3 matches found');
21 t.equal(wildcard('a.*.c', testdata).length, 1);
22 t.equal(wildcard('b.*.d', testdata).length, 0);
23});
24
25test('array result with separator matching tests', function(t) {
26 t.plan(4);
27
28 t.equal(wildcard('a:*', testdataSep, ':').length, 4, '4 matches found');
29 t.equal(wildcard('a:b:*', testdataSep, ':').length, 3, '3 matches found');
30 t.equal(wildcard('a:*:c', testdataSep, ':').length, 1);
31 t.equal(wildcard('b:*:d', testdataSep, ':').length, 0);
32});