Sha256: 66807a89a361d72379a3bcc8f1ab16abd3190e11875144b181b706494a8ed0e4

Contents?: true

Size: 1.34 KB

Versions: 21

Compression:

Stored size: 1.34 KB

Contents

var test = require('tape'),
walkdir = require('../walkdir.js');

var expectedPaths = {
'dir/foo/x':'file',
'dir/foo/a':'dir',
'dir/foo/a/y':'file',
'dir/foo/a/b':'dir',
'dir/foo/a/b/z':'file',
'dir/foo/a/b/c':'dir',
'dir/foo/a/b/c/w':'file'
};

test('sync',function(t){
  var paths = [],
  files = [],
  dirs = [];

  var pathResult = walkdir.sync(__dirname+'/dir/foo',function(path){
    console.log('path: ',path);
    paths.push(path);
  });

  t.ok(pathResult instanceof Array,'if return object is not specified should be an array');

  t.equals(Object.keys(expectedPaths).length,paths.length,'should have found the same number of paths as expected');


  Object.keys(expectedPaths).forEach(function(v,k){

      t.ok(paths.indexOf(__dirname+'/'+v) > -1,v+' should be found');
  });

  t.deepEquals(paths,pathResult,'paths should be equal to pathResult');

  t.end();
});

test('sync return object',function(t){

  var pathResult = walkdir.sync(__dirname+'/dir/foo',{return_object:true});

  t.ok(!(pathResult instanceof Array),'if return object is not specified should be an array');

  t.equals(Object.keys(expectedPaths).length,Object.keys(pathResult).length,'should find the same number of paths as expected');

  Object.keys(expectedPaths).forEach(function(v,k){
      t.ok(pathResult[__dirname+'/'+v],'should  find path in result object');
  });

  t.end();
});

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
ela-4.1.6 node_modules/walkdir/test/sync.js
ela-4.1.5 node_modules/walkdir/test/sync.js
ela-4.1.4 node_modules/walkdir/test/sync.js
ela-4.1.3 node_modules/walkdir/test/sync.js
ela-4.1.2 node_modules/walkdir/test/sync.js
ela-4.1.1 node_modules/walkdir/test/sync.js
ela-4.1.0 node_modules/walkdir/test/sync.js
ela-4.0.0 node_modules/walkdir/test/sync.js
ela-3.4.3 node_modules/walkdir/test/sync.js
ela-3.4.2 node_modules/walkdir/test/sync.js
ela-3.4.0 node_modules/walkdir/test/sync.js
ela-3.3.1 node_modules/walkdir/test/sync.js
ela-3.3.0 node_modules/walkdir/test/sync.js
ela-3.2.0 node_modules/walkdir/test/sync.js
ela-3.1.1 node_modules/walkdir/test/sync.js
ela-3.1.0 node_modules/walkdir/test/sync.js
ela-3.0.0 node_modules/walkdir/test/sync.js
ela-2.0.0 node_modules/walkdir/test/sync.js
ela-1.1.0 node_modules/walkdir/test/sync.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/walkdir/test/sync.js