Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Jan 8, 2018
1 parent af682a2 commit f290365
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
9 changes: 8 additions & 1 deletion test/api.compile.js
Expand Up @@ -35,7 +35,14 @@ describe('.compile()', function() {
{ type: 'bos', val: '' },
{ type: 'text', val: 'a' },
{ type: 'slash', val: '/' },
{ type: 'globstar', val: '**' },
{
type: 'globstar',
val: '**',
isInside: {
brace: false,
paren: false
}
},
{ type: 'slash', val: '/' },
{ type: 'star', val: '*' },
{ type: 'eos', val: '' }
Expand Down
2 changes: 1 addition & 1 deletion test/api.makeRe.js
Expand Up @@ -15,6 +15,6 @@ describe('.makeRe()', function() {
});

it('should create a regex for a string', function() {
assert.deepEqual(mm.makeRe('abc').source, '^(?:abc)$');
assert.deepEqual(mm.makeRe('abc').source, '^(?:(?:(?:\\.(?:\\/|\\\\))(?=.))?abc)$');
});
});
10 changes: 9 additions & 1 deletion test/api.parse.js
Expand Up @@ -28,14 +28,22 @@ describe('.parse()', function() {

ast = mm.parse('a/**/*');
delete ast.state;

assert.deepEqual(ast, {
type: 'root',
errors: [],
nodes: [
{ type: 'bos', val: '' },
{ type: 'text', val: 'a' },
{ type: 'slash', val: '/' },
{ type: 'globstar', val: '**' },
{
type: 'globstar',
val: '**',
isInside: {
brace: false,
paren: false
}
},
{ type: 'slash', val: '/' },
{ type: 'star', val: '*' },
{ type: 'eos', val: '' }
Expand Down
2 changes: 1 addition & 1 deletion test/bash.js
Expand Up @@ -152,7 +152,7 @@ describe('bash options and features:', function() {
});

it('should not expand literal braces inside brackets', function() {
assert.deepEqual(mm.makeRe('foo[{a,b}]+baz'), /^(?:foo[{a,b}]+baz)$/);
assert.deepEqual(mm.makeRe('foo[{a,b}]+baz'), /^(?:(?:(?:\.(?:\/|\\))(?=.))?foo[{a,b}]+baz)$/);
assert(match.isMatch('foo{}baz', 'foo[{a,b}]+baz'));
});

Expand Down
6 changes: 3 additions & 3 deletions test/brackets.js
Expand Up @@ -5,7 +5,7 @@ var mm = require('./support/match');

function create(pattern, options) {
return mm.create(pattern, options).map(function(obj) {
return obj.output;
return obj.output.replace('(?:(?:\\.(?:\\/|\\\\))(?=.))?', '');
}).join('|');
}

Expand Down Expand Up @@ -132,8 +132,8 @@ describe('brackets', function() {

describe('.makeRe()', function() {
it('should make a regular expression for the given pattern:', function() {
assert.deepEqual(mm.makeRe('[[:alpha:]123]'), /^(?:[a-zA-Z123])$/);
assert.deepEqual(mm.makeRe('[![:lower:]]'), /^(?:[^a-z])$/);
assert.deepEqual(mm.makeRe('[[:alpha:]123]'), /^(?:(?:(?:\.(?:\/|\\))(?=.))?[a-zA-Z123])$/);
assert.deepEqual(mm.makeRe('[![:lower:]]'), /^(?:(?:(?:\.(?:\/|\\))(?=.))?[^a-z])$/);
});
});

Expand Down

0 comments on commit f290365

Please sign in to comment.