-
-
Notifications
You must be signed in to change notification settings - Fork 142
/
api.compile.js
47 lines (43 loc) · 1.11 KB
/
api.compile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict';
var path = require('path');
var assert = require('assert');
var mm = require('..');
describe('.compile()', function() {
it('should throw an error when arguments are invalid', function() {
assert.throws(function() {
mm.compile();
});
});
it('should return an AST for a glob', function() {
var foo = mm.compile('a/*');
delete foo.ast.state;
assert.deepEqual(foo.ast, {
type: 'root',
errors: [],
nodes: [
{ type: 'bos', val: '' },
{ type: 'text', val: 'a' },
{ type: 'slash', val: '/' },
{ type: 'star', val: '*' },
{ type: 'eos', val: '' }
],
input: 'a/*'
});
var bar = mm.compile('a/**/*');
delete bar.ast.state;
assert.deepEqual(bar.ast, {
type: 'root',
errors: [],
nodes: [
{ type: 'bos', val: '' },
{ type: 'text', val: 'a' },
{ type: 'slash', val: '/' },
{ type: 'globstar', val: '**' },
{ type: 'slash', val: '/' },
{ type: 'star', val: '*' },
{ type: 'eos', val: '' }
],
input: 'a/**/*'
});
});
});