[Pkg-javascript-commits] [node-coveralls] 50/332: add some tests. version bump to 2.0.13.
Bastien Roucariès
rouca at moszumanska.debian.org
Thu Nov 9 13:53:39 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-coveralls.
commit 45738a0b1851bdf161c6508f52e9c51cf776172d
Author: cainus <gregg at caines.ca>
Date: Sat Jun 8 11:38:13 2013 -0700
add some tests. version bump to 2.0.13.
---
lib/handleInput.js | 10 ++++-----
lib/sendToCoveralls.js | 2 +-
package.json | 5 +++--
test/getOptions.js | 17 +++++++++++++++
test/handleInput.js | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
test/sendToCoveralls.js | 27 ++++++++++++++++++++++++
6 files changed, 107 insertions(+), 9 deletions(-)
diff --git a/lib/handleInput.js b/lib/handleInput.js
index a354efa..0ea17a9 100644
--- a/lib/handleInput.js
+++ b/lib/handleInput.js
@@ -1,20 +1,18 @@
-var sendToCoveralls = require('../index').sendToCoveralls;
-var convertLcovToCoveralls = require('../index').convertLcovToCoveralls;
+var index = require('../index');
var logger = require('./logger');
-var getOptions = require('../index').getOptions;
var handleInput = function(input){
logger.debug(input);
- var options = getOptions();
+ var options = index.getOptions();
logger.debug(options);
- convertLcovToCoveralls(input, options, function(err, postData){
+ index.convertLcovToCoveralls(input, options, function(err, postData){
if (err){
logger.error("error from convertLcovToCoveralls");
throw err;
}
logger.info("sending this to coveralls.io: ", JSON.stringify(postData));
- sendToCoveralls(postData, function(err, response, body){
+ index.sendToCoveralls(postData, function(err, response, body){
if (err){
throw err;
}
diff --git a/lib/sendToCoveralls.js b/lib/sendToCoveralls.js
index b3514c6..10e614d 100644
--- a/lib/sendToCoveralls.js
+++ b/lib/sendToCoveralls.js
@@ -3,7 +3,7 @@ var request = require('request');
var sendToCoveralls = function(obj, cb){
var str = JSON.stringify(obj);
var url = 'https://coveralls.io/api/v1/jobs';
- request({url : url, method : 'POST', form : { json : str}}, function(err, response, body){
+ request.post({url : url, form : { json : str}}, function(err, response, body){
cb(err, response, body);
});
};
diff --git a/package.json b/package.json
index f17edbb..bd917cf 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,7 @@
"coverage",
"coveralls"
],
- "version": "2.0.12",
+ "version": "2.0.13",
"bugs": {
"url": "https://github.com/cainus/node-coveralls/issues"
},
@@ -22,7 +22,7 @@
"Alan Gutierrez <alan at prettyrobots.com> (http://www.prettyrobots.com/)",
"Kir Belevich (https://github.com/svg)",
"elliotcable <github at elliottcable.name> (http://elliottcable.name/)",
- "Arpad Borsos <arpad.borsos at googlemail.com> (http://swatinem.de/)"
+ "Arpad Borsos <arpad.borsos at googlemail.com> (http://swatinem.de/)"
],
"dependencies": {
"yaml": "0.2.3",
@@ -31,6 +31,7 @@
"log-driver": "1.2.1"
},
"devDependencies": {
+ "sinon-restore": "1.0.0",
"mocha-lcov-reporter": "0.0.1",
"mocha": "1.8.1",
"should": "1.1.0",
diff --git a/test/getOptions.js b/test/getOptions.js
new file mode 100644
index 0000000..e8e3c7a
--- /dev/null
+++ b/test/getOptions.js
@@ -0,0 +1,17 @@
+var should = require('should');
+var getOptions = require('../index').getOptions;
+
+describe("getOptions", function(){
+ it ("should get a filepath if there is one", function(){
+ process.argv[2] = "somepath";
+ getOptions().filepath.should.equal("somepath");
+
+ });
+ it ("should get a filepath if there is one, even in verbose mode", function(){
+ process.argv[2] = "--verbose";
+ process.argv[3] = "somepath";
+ getOptions().filepath.should.equal("somepath");
+
+ });
+
+});
diff --git a/test/handleInput.js b/test/handleInput.js
new file mode 100644
index 0000000..45f0482
--- /dev/null
+++ b/test/handleInput.js
@@ -0,0 +1,55 @@
+var should = require('should');
+var sinon = require('sinon-restore');
+var index = require('../index');
+var fs = require('fs');
+logger = require('log-driver')({level : false});
+
+describe("handleInput", function(){
+ afterEach(function() {
+ sinon.restoreAll();
+ });
+ it ("throws an error when there's an error sending", function(done){
+ sinon.stub(index, 'getOptions', function(){
+ return {};
+ });
+ sinon.stub(index, 'sendToCoveralls', function(postData, cb){
+ try {
+ cb("some error");
+ should.fail("expected exception was not raised");
+ } catch (ex) {
+ done();
+ }
+ });
+ var path = __dirname + "/../fixtures/onefile.lcov";
+ var input = fs.readFileSync(path, "utf8");
+ index.handleInput(input);
+ });
+ it ("throws an error when there's a bad status code", function(done){
+ sinon.stub(index, 'getOptions', function(){
+ return {};
+ });
+ sinon.stub(index, 'sendToCoveralls', function(postData, cb){
+ try {
+ cb(null, {statusCode : 500}, "body");
+ should.fail("expected exception was not raised");
+ } catch (ex) {
+ done();
+ }
+ });
+ var path = __dirname + "/../fixtures/onefile.lcov";
+ var input = fs.readFileSync(path, "utf8");
+ index.handleInput(input);
+ });
+ it ("completes successfully when there are now errors", function(done){
+ sinon.stub(index, 'getOptions', function(){
+ return {};
+ });
+ sinon.stub(index, 'sendToCoveralls', function(postData, cb){
+ cb(null, {statusCode : 200}, "body");
+ done();
+ });
+ var path = __dirname + "/../fixtures/onefile.lcov";
+ var input = fs.readFileSync(path, "utf8");
+ index.handleInput(input);
+ });
+});
diff --git a/test/sendToCoveralls.js b/test/sendToCoveralls.js
new file mode 100644
index 0000000..937df95
--- /dev/null
+++ b/test/sendToCoveralls.js
@@ -0,0 +1,27 @@
+var should = require('should');
+var request = require('request');
+var sinon = require('sinon-restore');
+var index = require('../index');
+logger = require('log-driver')({level : false});
+
+describe("sendToCoveralls", function(){
+ afterEach(function() {
+ sinon.restoreAll();
+ });
+ it ("passes on the correct params to request.post", function(done){
+ sinon.stub(request, 'post', function(obj, cb){
+ obj.url.should.equal('https://coveralls.io/api/v1/jobs');
+ obj.form.should.eql({json : '{"some":"obj"}'});
+ cb('err', 'response', 'body');
+ });
+
+ var obj = {"some":"obj"};
+ index.sendToCoveralls(obj, function(err, response, body){
+ err.should.equal('err');
+ response.should.equal('response');
+ body.should.equal('body');
+ done();
+
+ });
+ });
+});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-coveralls.git
More information about the Pkg-javascript-commits
mailing list