-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Paths computed from node's path modules often do not end in with a slash, this replacement fails if there is no slash... which it was not meant to. (we already know the path points to a directory...
- Loading branch information
Showing
2 changed files
with
51 additions
and
1 deletion.
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,50 @@ | ||
import { parseFoldersToGlobs } from '../src/utils'; | ||
|
||
jest.mock('fs', () => { | ||
return { | ||
statSync(pattern) { | ||
return { | ||
isDirectory() { | ||
return pattern.indexOf('/path/') === 0; | ||
}, | ||
}; | ||
}, | ||
}; | ||
}); | ||
|
||
test('parseFoldersToGlobs should return globs for folders', () => { | ||
const withoutSlash = '/path/to/code'; | ||
const withSlash = `${withoutSlash}/`; | ||
|
||
expect(parseFoldersToGlobs(withoutSlash, 'js')).toMatchInlineSnapshot(` | ||
Array [ | ||
"/path/to/code/**/*.js", | ||
] | ||
`); | ||
expect(parseFoldersToGlobs(withSlash, 'js')).toMatchInlineSnapshot(` | ||
Array [ | ||
"/path/to/code/**/*.js", | ||
] | ||
`); | ||
|
||
expect( | ||
parseFoldersToGlobs( | ||
[withoutSlash, withSlash, '/some/file.js'], | ||
['js', 'cjs', 'mjs'] | ||
) | ||
).toMatchInlineSnapshot(` | ||
Array [ | ||
"/path/to/code/**/*.{js,cjs,mjs}", | ||
"/path/to/code/**/*.{js,cjs,mjs}", | ||
"/some/file.js", | ||
] | ||
`); | ||
}); | ||
|
||
test('parseFoldersToGlobs should return unmodified globs for globs (ignoring extensions)', () => { | ||
expect(parseFoldersToGlobs('**.notjs', 'js')).toMatchInlineSnapshot(` | ||
Array [ | ||
"**.notjs", | ||
] | ||
`); | ||
}); |