diff options
Diffstat (limited to 'test/sendToCoveralls.js')
| -rw-r--r-- | test/sendToCoveralls.js | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/test/sendToCoveralls.js b/test/sendToCoveralls.js index 937df95..f809319 100644 --- a/test/sendToCoveralls.js +++ b/test/sendToCoveralls.js @@ -5,9 +5,20 @@ var index = require('../index'); logger = require('log-driver')({level : false}); describe("sendToCoveralls", function(){ + var realCoverallsHost; + beforeEach(function() { + realCoverallsHost = process.env.COVERALLS_ENDPOINT; + }); + afterEach(function() { sinon.restoreAll(); + if (realCoverallsHost !== undefined) { + process.env.COVERALLS_ENDPOINT = realCoverallsHost; + } else { + delete process.env.COVERALLS_ENDPOINT; + } }); + 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'); @@ -16,12 +27,28 @@ 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 ("allows sending to enterprise url", function(done){ + process.env.COVERALLS_ENDPOINT = 'https://coveralls-ubuntu.domain.com'; + sinon.stub(request, 'post', function(obj, cb){ + obj.url.should.equal('https://coveralls-ubuntu.domain.com/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(); - }); }); }); |
