import { expect } from 'chai'; import { glob } from '..'; describe('glob', () => { describe('find', () => { it('finds several files', async () => { const pattern = `${__dirname}/glob*.ts`; const result = await glob.find(pattern); expect(result.length).to.eql(2); expect(result[0].endsWith('glob.test.ts')).to.eql(true); expect(result[1].endsWith('glob.ts')).to.eql(true); }); }); describe('match', () => { it('is a match', () => { expect(glob.isMatch('*.foo', 'bar.foo')).to.eql(true); expect(glob.isMatch('**/*.ts', '/foo/bar/file.ts')).to.eql(true); }); it('is not a match', () => { expect(glob.isMatch('*.bar', 'bar.foo')).to.eql(false); }); it('curries pattern (matcher)', () => { const match = glob.matcher('**/foo/*.ts'); expect(match('/root/foo/file.ts')).to.eql(true); expect(match('/root/child/foo/file.ts')).to.eql(true); expect(match('/root/bar/file.ts')).to.eql(false); }); }); });