@infinito/get-files
Version:
Recursively get all files of a certain type in a directory
17 lines (15 loc) • 679 B
JavaScript
import assert from 'assert';
import fs from 'fs';
import path from 'path';
import getFiles from '../src/index.js';
describe('getFiles', function () {
it('should return an empty array when given an invalid directory', function () {
assert.deepStrictEqual([],getFiles("THIS IS A TEST",""));
});
it('should return an empty array when searching for .mp3s in src/', function () {
assert.deepStrictEqual(getFiles(path.resolve(__dirname,'..','src'),".mp3"),[]);
});
it('should return an array with many elements searching in node_modules folder', function () {
assert.doesNotThrow(() => getFiles(path.resolve(__dirname,'..','node_modules'),'.js'));
});
});