Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / walkdir / test / custom_fs.js
1 var test = require('tape'),
2 _fs = require('fs'),
3 walkdir = require('../walkdir.js');
4
5 var expectedPaths = {};
6
7 test('fs option',function(t){
8   var paths = [];
9
10   var emitter = walkdir(__dirname+'/dir/foo',{fs:
11     {
12       readdir: function () {
13         var cb = arguments[arguments.length - 1];
14         cb(null, []);
15       },
16       lstat: function (file) {
17         var cb = arguments[arguments.length - 1];
18         return _fs.lstat(__dirname, cb);
19       }
20     }
21   },function(path,stat,depth){
22     t.fail('there should be no files emitted');
23   });
24
25   emitter.on('end',function(){
26      var expected = Object.keys(expectedPaths);
27      t.ok(expected.length == paths.length, 'expected and emitted paths should have the same length');
28      paths.forEach(function(v){ 
29           t.ok(expected.indexOf(v) > -1,'all expected files should be in paths');
30      });
31
32      t.end();
33   });
34 });