Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / walkdir / test / async.js
diff --git a/legacy-libs/walkdir/test/async.js b/legacy-libs/walkdir/test/async.js
new file mode 100644 (file)
index 0000000..f7bf635
--- /dev/null
@@ -0,0 +1,33 @@
+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);
+  })
+})