-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
path: add
path.glob
and path.globToRegExp
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { describe, it } from 'node:test'; | ||
import * as assert from 'node:assert'; | ||
import * as path from 'node:path'; | ||
|
||
describe('path.glob', () => { | ||
it('should return a filter function', () => { | ||
const fn = path.glob('*.js'); | ||
assert.strictEqual(typeof fn, 'function'); | ||
}); | ||
it('should return a filter function that matches the glob', () => { | ||
const fn = path.glob('*.js'); | ||
assert.strictEqual(fn('foo.js'), true); | ||
}); | ||
}); | ||
|
||
describe('path.globToRegExp', () => { | ||
it('should return a RegExp', () => { | ||
const re = path.globToRegExp('foo'); | ||
assert.strictEqual(re instanceof RegExp, true); | ||
}); | ||
it('should return a RegExp that matches the glob', () => { | ||
const re = path.globToRegExp('*.js'); | ||
assert.strictEqual(re.test('foo.js'), true); | ||
}) | ||
}); |