UNPKG

1.01 kBPlain TextView Raw
1import { expect } from 'chai';
2import { glob } from '..';
3
4describe('glob', () => {
5 describe('find', () => {
6 it('finds several files', async () => {
7 const pattern = `${__dirname}/glob*.ts`;
8 const result = await glob.find(pattern);
9 expect(result.length).to.eql(2);
10 expect(result[0].endsWith('glob.test.ts')).to.eql(true);
11 expect(result[1].endsWith('glob.ts')).to.eql(true);
12 });
13 });
14
15 describe('match', () => {
16 it('is a match', () => {
17 expect(glob.isMatch('*.foo', 'bar.foo')).to.eql(true);
18 expect(glob.isMatch('**/*.ts', '/foo/bar/file.ts')).to.eql(true);
19 });
20
21 it('is not a match', () => {
22 expect(glob.isMatch('*.bar', 'bar.foo')).to.eql(false);
23 });
24
25 it('curries pattern (matcher)', () => {
26 const match = glob.matcher('**/foo/*.ts');
27 expect(match('/root/foo/file.ts')).to.eql(true);
28 expect(match('/root/child/foo/file.ts')).to.eql(true);
29 expect(match('/root/bar/file.ts')).to.eql(false);
30 });
31 });
32});