1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 16:13:18 +00:00
musix-oss/node_modules/walkdir/test/async.js
2020-03-03 22:30:50 +02:00

34 lines
833 B
JavaScript

var test = require('tape');
var walkdir = require('../walkdir.js');
var path = require('path');
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("can use async method with promise",(t)=>{
if(typeof Promise === 'undefined'){
console.log('cannot use async promise returning methods in runtime without Promise')
return t.end()
}
var p = walkdir.async(path.join(__dirname,'dir'))
p.then(function(result){
result = result.map(function(p){
return p.replace(__dirname,'')
})
t.ok(result.indexOf('/dir/symlinks/dir1/dangling-symlink') > -1,'should be a list of found files and have found one in particular')
t.end()
}).catch(function(e){
t.fail(e);
})
})