diff options
| author | cainus <[email protected]> | 2013-06-08 11:38:13 -0700 |
|---|---|---|
| committer | cainus <[email protected]> | 2013-06-08 11:38:13 -0700 |
| commit | 45738a0b1851bdf161c6508f52e9c51cf776172d (patch) | |
| tree | 3ac1c9f34d6ab6ea6098c5cb76a0a22c0fa48c99 /test/handleInput.js | |
| parent | 85a98465ec1f777bd55f99ab276ce526a487b9cd (diff) | |
| download | node-coveralls-45738a0b1851bdf161c6508f52e9c51cf776172d.tar.xz node-coveralls-45738a0b1851bdf161c6508f52e9c51cf776172d.zip | |
add some tests. version bump to 2.0.13.
Diffstat (limited to 'test/handleInput.js')
| -rw-r--r-- | test/handleInput.js | 55 |
1 files changed, 55 insertions, 0 deletions
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); + }); +}); |
