Skip to content

Instantly share code, notes, and snippets.

@roryf
Last active August 29, 2015 14:11
Show Gist options
  • Save roryf/a80d88211ad952c3291b to your computer and use it in GitHub Desktop.
Save roryf/a80d88211ad952c3291b to your computer and use it in GitHub Desktop.
How do I test this?
module.exports = function(input, output, cb) {
input.on('data', function(chunk) {
// do somethink with chunk, possibly transform it
output.write(chunk);
});
input.on('end', function() {
cb();
});
};
var Readable = require('stream').Readable;
var Writable = require('stream').Writable;
var test = require('tape');
var subject = require('./subject');
test('it writes input to output stream', function(t) {
var result = '';
var input = new Readable();
var output = new Writable();
subject(input, output, function() {
t.equal(result, 'I have no idea what I am doing.');
t.end();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment