aboutsummaryrefslogtreecommitdiff
path: root/node_modules/walkdir/test/custom_fs.js
blob: 3de07b98ed3be3c379270055727a0f44c200ff03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var test = require('tape'),
_fs = require('fs'),
walkdir = require('../walkdir.js');

var expectedPaths = {};

test('fs option',function(t){
  var paths = [];

  var emitter = walkdir(__dirname+'/dir/foo',{fs:
    {
      readdir: function () {
        var cb = arguments[arguments.length - 1];
        cb(null, []);
      },
      lstat: function (file) {
        var cb = arguments[arguments.length - 1];
        return _fs.lstat(__dirname, cb);
      }
    }
  },function(path,stat,depth){
    t.fail('there should be no files emitted');
  });

  emitter.on('end',function(){
     var expected = Object.keys(expectedPaths);
     t.ok(expected.length == paths.length, 'expected and emitted paths should have the same length');
     paths.forEach(function(v){ 
          t.ok(expected.indexOf(v) > -1,'all expected files should be in paths');
     });

     t.end();
  });
});