synapse_fs
Version:
A simple file search utility.
29 lines (23 loc) • 1.26 kB
JavaScript
//Run all tests from the root folder of the project
//TEST 1: Doesn't crash when empty folder is detected as root search.
//var syn = require('synapse_fs');
var syn = require('./file_search_engine');
function callback (fileSearchResults){console.log(fileSearchResults);};
var options = {searchPath: './test/empty', maxDepth: 1};
new syn(options, callback).list();
//Test 2: Depth count test
var options = {searchPath: './test', maxDepth: 5};
new syn(options, callback).list();
//Test 3: Doesn't crash when empty folder is detected at a depth other than root.
var options = {searchPath: './', maxDepth: 1};
new syn(options, callback).list();
//TEST 4: Read Dir Errors. When Read Dir throws an error, stop everything and call back.
var options = {searchPath: './sdfsdf', maxDepth: 1};
new syn(options, callback).list();
//Test 5: Don't crash when you are unable to get stats for a file (virtual file system files for example: .gvfs)
var options = {searchPath: './', maxDepth: 0};
new syn(options, callback).list();
//Test 6: Root folder test
var options = {searchPath: '/', maxDepth: 0};
new syn(options, callback).list();
fs.readdir('./test', function(error, list){list.forEach(function (fileName){console.log(fileName);});});