//
// ## Test DirStream
//
var assert = require('assert');
var dirstream = require('../dirstream').DirStream;
var path = __dirname + '/foo';

suite('DirStream', function () {

  test('Count is correct', function (done) {
    var d = new dirstream(path);
    d.on('count', function (count) {
      assert(count, 5, 'Got count wrong.');
      done();
    });
  });

  test('Count works after filter', function (done) {
    var d = new dirstream(path, /.txt$/);
    d.on('count', function (count) {
      assert(count, 3, 'Filter not applied correctly.');
      done();
    });
  });

  test('Pause/resume works.', function (done) {
    var d = new dirstream(path);
    var count = 0;
    d.on('data', function (file) {
      count++;
      if (count == 3) {
        d.pause();
        setTimeout(function () {
          assert(count, 3, 'Pause does not work.');
          d.resume();
        }, 20);
      }
    });
    d.on('end', function () {
      done();
    });
  });

});


@@ -966,13 +966,412 @@
 %0A  %7D);%0A%0A
+  test('Pipe works.', function (done) %7B%0A    var d = new dirstream(path);%0A    var piped = 0;%0A    var stream = new require('stream')();%0A    stream.writable = true;%0A    stream.write = function(file) %7B%0A      piped++;%0A    %7D;%0A    stream.end = function() %7B%0A      assert(piped, 5, 'Piped count wrong.');%0A      done();%0A    %7D;%0A    d.pipe(stream);%0A    stream.emit('drain');%0A    // or%0A    // d.resume();%0A  %7D);%0A%0A
 %7D);%0A%0A

Add test submited by @kesla: https://github.com/simme/node-dirstream/issues/3#issuecomment-10052443