Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / walkdir / test / nofailemptydir.js
1 var test = require('tape'),
2 fs = require('fs'),
3 path = require('path'),
4 walk  = require('../walkdir.js');
5
6 test('should not emit fail events for empty dirs',function(t){
7   fs.mkdir('./empty',function(err,data){
8     if(err) {
9       t.equals(err.code,'EEXIST','if error code on mkdir for fixture it should only be because it exists already');
10     }
11
12     var paths = [];
13     var dirs = [];
14     var emptys = [];
15     var fails = [];
16
17     var em = walk('./');
18
19     em.on('fail',function(path,err){
20       fails.push(path); 
21     });
22
23     em.on('empty',function(path,err){
24       emptys.push(path); 
25     });
26
27     em.on('end',function(){
28       t.equals(fails.length,0,'should not have any fails');
29       t.equals(path.basename(emptys[0]),'empty','should find empty dir');
30       t.end();
31     });
32   });
33 });
34