Skip to content

Instantly share code, notes, and snippets.

@paolochiodi
Created November 8, 2013 08:03
Show Gist options
  • Save paolochiodi/7367759 to your computer and use it in GitHub Desktop.
Save paolochiodi/7367759 to your computer and use it in GitHub Desktop.
var Cover = require('../../lib/resizers/resizer_stream');
var Transform = require('stream').Transform;
describe("ResizerStream", function() {
it("should be a Transform stream", function() {
var resizer = new Cover({ height: 100, width: 200 });
expect(resizer).to.be.an.instanceof(Transform);
});
it("should emit an error if graphics magick exits with code != 0", function(end) {
var stream = require('stream');
var process = require('child_process');
var convert = {
stdin: new stream.Writable(),
stdout: new stream.Readable(),
stderr: new stream.Readable()
};
convert.stdin.on('*', function() {
convert.emit('error');
});
sinon.stub(process, 'spawn', function() {
console.log('spawn');
return convert;
});
var resizer = new Cover({ height: 100, width: 200 });
resizer.on('error', function() {
end();
});
resizer.write('data');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment