diff options
| author | Nick Merwin <[email protected]> | 2019-11-20 17:05:48 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-11-20 17:05:48 -0800 |
| commit | 336123fe05e7f80d79fc8522b4ff21a60fffe77c (patch) | |
| tree | 97e5b9343471fc73ddf4ffb20cd71ca58367d6c6 /test/handleInput.js | |
| parent | eba01a29c69f28ffd7f50556492a43b5ba2486d7 (diff) | |
| download | node-coveralls-336123fe05e7f80d79fc8522b4ff21a60fffe77c.tar.xz node-coveralls-336123fe05e7f80d79fc8522b4ff21a60fffe77c.zip | |
ES6
* remove unused variables
* move `require`s at the top
* check for prototype built-ins
* run in strict mode
* always check for error values in tests
* make style consistent
* mark Node.js 6 as the minimum supported version in package.json
* Use the arrow return syntax
* logger.js: use `Boolean` to make the intention clearer.
* Use the rest params instead of arguments.
* test/getOptions.js: beautify git data.
* Update logger.js
Remove `hasDebugEnvVariable` function; it's just a `process.env` check
* Create .jshintrc
Diffstat (limited to 'test/handleInput.js')
| -rw-r--r-- | test/handleInput.js | 110 |
1 files changed, 52 insertions, 58 deletions
diff --git a/test/handleInput.js b/test/handleInput.js index bca7b16..46cbe50 100644 --- a/test/handleInput.js +++ b/test/handleInput.js @@ -1,78 +1,72 @@ -var sysPath = require('path'); -var should = require('should'); -var sinon = require('sinon-restore'); -var index = require('../index'); -var fs = require('fs'); -logger = require('log-driver')({level : false}); +'use strict'; -describe("handleInput", function(){ - afterEach(function() { - sinon.restoreAll(); - }); - it ("returns an error when there's an error getting options", function(done){ - sinon.stub(index, 'getOptions', function(cb){ - return cb("some error", {}); - }); - var path = sysPath.join(__dirname, "/../fixtures/onefile.lcov"); - var input = fs.readFileSync(path, "utf8"); - index.handleInput(input, function(err){ - err.should.equal("some error"); +const fs = require('fs'); +const sysPath = require('path'); +const should = require('should'); +const sinon = require('sinon-restore'); +const logDriver = require('log-driver'); +const index = require('..'); + +logDriver({ level: false }); + +describe('handleInput', () => { + afterEach(() => { + sinon.restoreAll(); + }); + it('returns an error when there\'s an error getting options', done => { + sinon.stub(index, 'getOptions', cb => cb('some error', {})); + const path = sysPath.join(__dirname, '/../fixtures/onefile.lcov'); + const input = fs.readFileSync(path, 'utf8'); + index.handleInput(input, err => { + err.should.equal('some error'); done(); }); }); - it ("returns an error when there's an error converting", function(done){ - sinon.stub(index, 'getOptions', function(cb){ - return cb(null, {}); + it('returns an error when there\'s an error converting', done => { + sinon.stub(index, 'getOptions', cb => cb(null, {})); + sinon.stub(index, 'convertLcovToCoveralls', (input, options, cb) => { + cb('some error'); }); - sinon.stub(index, 'convertLcovToCoveralls', function(input, options, cb){ - cb("some error"); - }); - var path = sysPath.join(__dirname, "/../fixtures/onefile.lcov"); - var input = fs.readFileSync(path, "utf8"); - index.handleInput(input, function(err){ - err.should.equal("some error"); + const path = sysPath.join(__dirname, '/../fixtures/onefile.lcov'); + const input = fs.readFileSync(path, 'utf8'); + index.handleInput(input, err => { + err.should.equal('some error'); done(); }); }); - it ("returns an error when there's an error sending", function(done){ - sinon.stub(index, 'getOptions', function(cb){ - return cb(null, {}); - }); - sinon.stub(index, 'sendToCoveralls', function(postData, cb){ - cb("some error"); + it('returns an error when there\'s an error sending', done => { + sinon.stub(index, 'getOptions', cb => cb(null, {})); + sinon.stub(index, 'sendToCoveralls', (postData, cb) => { + cb('some error'); }); - var path = sysPath.join(__dirname, "/../fixtures/onefile.lcov"); - var input = fs.readFileSync(path, "utf8"); - index.handleInput(input, function(err){ - err.should.equal("some error"); + const path = sysPath.join(__dirname, '/../fixtures/onefile.lcov'); + const input = fs.readFileSync(path, 'utf8'); + index.handleInput(input, err => { + err.should.equal('some error'); done(); }); }); - it ("returns an error when there's a bad status code", function(done){ - sinon.stub(index, 'getOptions', function(cb){ - return cb(null, {}); + it('returns an error when there\'s a bad status code', done => { + sinon.stub(index, 'getOptions', cb => cb(null, {})); + sinon.stub(index, 'sendToCoveralls', (postData, cb) => { + cb(null, { statusCode: 500 }, 'body'); }); - sinon.stub(index, 'sendToCoveralls', function(postData, cb){ - cb(null, {statusCode : 500}, "body"); - }); - var path = sysPath.join(__dirname, "/../fixtures/onefile.lcov"); - var input = fs.readFileSync(path, "utf8"); - index.handleInput(input, function(err){ - err.should.equal("Bad response: 500 body"); + const path = sysPath.join(__dirname, '/../fixtures/onefile.lcov'); + const input = fs.readFileSync(path, 'utf8'); + index.handleInput(input, err => { + err.should.equal('Bad response: 500 body'); done(); }); }); - it ("completes successfully when there are no errors", function(done){ - sinon.stub(index, 'getOptions', function(cb){ - return cb(null, {}); - }); - sinon.stub(index, 'sendToCoveralls', function(postData, cb){ - cb(null, {statusCode : 200}, "body"); + it('completes successfully when there are no errors', done => { + sinon.stub(index, 'getOptions', cb => cb(null, {})); + sinon.stub(index, 'sendToCoveralls', (postData, cb) => { + cb(null, { statusCode: 200 }, 'body'); }); - var path = sysPath.join(__dirname, "/../fixtures/onefile.lcov"); - var input = fs.readFileSync(path, "utf8"); - index.handleInput(input, function(err, body){ - (err === null).should.equal(true); + const path = sysPath.join(__dirname, '/../fixtures/onefile.lcov'); + const input = fs.readFileSync(path, 'utf8'); + index.handleInput(input, (err, body) => { + should.not.exist(err); body.should.equal('body'); done(); }); |
