aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnna Henningsen <[email protected]>2015-02-04 01:46:30 +0100
committerAnna Henningsen <[email protected]>2015-12-10 22:14:39 +0100
commit7d9d9a4514c12c80b4c9475d57d674bf775c9149 (patch)
treeb28f1acc9da37a3fa619012906c6c3250aea0654 /test
parent3794d16027767014919116bd85a32e3d3de7efa8 (diff)
downloadnode-coveralls-7d9d9a4514c12c80b4c9475d57d674bf775c9149.tar.xz
node-coveralls-7d9d9a4514c12c80b4c9475d57d674bf775c9149.zip
Add command line option to write output to stdout
Adds the command line option pair -w/--write. These options indicate that the output should be written to standard output, rather than being posted to coveralls.io, which may be useful for debugging, mixed-language codebases (e.g. node addons with C++ code) etc.
Diffstat (limited to 'test')
-rw-r--r--test/sendToCoveralls.js25
1 files changed, 23 insertions, 2 deletions
diff --git a/test/sendToCoveralls.js b/test/sendToCoveralls.js
index f809319..eca6bef 100644
--- a/test/sendToCoveralls.js
+++ b/test/sendToCoveralls.js
@@ -1,6 +1,7 @@
var should = require('should');
var request = require('request');
var sinon = require('sinon-restore');
+var stream = require('stream');
var index = require('../index');
logger = require('log-driver')({level : false});
@@ -27,7 +28,7 @@ describe("sendToCoveralls", function(){
});
var obj = {"some":"obj"};
- index.sendToCoveralls(obj, function(err, response, body){
+ index.sendToCoveralls(obj, function(err, response, body){
err.should.equal('err');
response.should.equal('response');
body.should.equal('body');
@@ -44,11 +45,31 @@ describe("sendToCoveralls", function(){
});
var obj = {"some":"obj"};
- index.sendToCoveralls(obj, function(err, response, body){
+ index.sendToCoveralls(obj, function(err, response, body){
err.should.equal('err');
response.should.equal('response');
body.should.equal('body');
done();
});
});
+ it ("writes output to stdout when --write is passed", function(done) {
+ var obj = {"some":"obj"};
+
+ // set up mock process.stdout.write temporarily
+ var origStdoutWrite = process.stdout.write;
+ process.stdout.write = function(string) {
+ if (string == JSON.stringify(obj)) {
+ process.stdout.write = origStdoutWrite;
+ return done();
+ }
+
+ origStdoutWrite.apply(this, arguments);
+ };
+
+ process.argv[2] = '--write';
+
+ index.sendToCoveralls(obj, function(err, response, body) {
+ response.statusCode.should.equal(200);
+ });
+ });
});