Skip to content

Commit

Permalink
Update sinon to v7.5.0. (#288)
Browse files Browse the repository at this point in the history
Co-authored-by: Xavier <[email protected]>
  • Loading branch information
XhmikosR and guimard authored Apr 24, 2020
1 parent 844d765 commit eb6dc35
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 46 deletions.
146 changes: 116 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"nyc": "^14.1.1",
"should": "^9.0.2",
"shx": "^0.3.2",
"sinon-restore": "^1.0.1"
"sinon": "^7.5.0"
},
"engines": {
"node": ">=6"
Expand Down
22 changes: 11 additions & 11 deletions test/handleInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
const fs = require('fs');
const sysPath = require('path');
const should = require('should');
const sinon = require('sinon-restore');
const sinon = require('sinon').sandbox.create();
const logDriver = require('log-driver');
const index = require('..');

logDriver({ level: false });

describe('handleInput', () => {
afterEach(() => {
sinon.restoreAll();
sinon.restore();
});
it('returns an error when there\'s an error getting options', done => {
sinon.stub(index, 'getOptions', cb => cb('some error', {}));
sinon.stub(index, 'getOptions').callsFake(cb => cb('some error', {}));
const path = sysPath.join(__dirname, './fixtures/onefile.lcov');
const input = fs.readFileSync(path, 'utf8');
index.handleInput(input, err => {
Expand All @@ -23,8 +23,8 @@ describe('handleInput', () => {
});
});
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) => {
sinon.stub(index, 'getOptions').callsFake(cb => cb(null, {}));
sinon.stub(index, 'convertLcovToCoveralls').callsFake((input, options, cb) => {
cb('some error');
});
const path = sysPath.join(__dirname, './fixtures/onefile.lcov');
Expand All @@ -35,8 +35,8 @@ describe('handleInput', () => {
});
});
it('returns an error when there\'s an error sending', done => {
sinon.stub(index, 'getOptions', cb => cb(null, {}));
sinon.stub(index, 'sendToCoveralls', (postData, cb) => {
sinon.stub(index, 'getOptions').callsFake(cb => cb(null, {}));
sinon.stub(index, 'sendToCoveralls').callsFake((postData, cb) => {
cb('some error');
});
const path = sysPath.join(__dirname, './fixtures/onefile.lcov');
Expand All @@ -47,8 +47,8 @@ describe('handleInput', () => {
});
});
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) => {
sinon.stub(index, 'getOptions').callsFake(cb => cb(null, {}));
sinon.stub(index, 'sendToCoveralls').callsFake((postData, cb) => {
cb(null, { statusCode: 500 }, 'body');
});
const path = sysPath.join(__dirname, './fixtures/onefile.lcov');
Expand All @@ -59,8 +59,8 @@ describe('handleInput', () => {
});
});
it('completes successfully when there are no errors', done => {
sinon.stub(index, 'getOptions', cb => cb(null, {}));
sinon.stub(index, 'sendToCoveralls', (postData, cb) => {
sinon.stub(index, 'getOptions').callsFake(cb => cb(null, {}));
sinon.stub(index, 'sendToCoveralls').callsFake((postData, cb) => {
cb(null, { statusCode: 200 }, 'body');
});
const path = sysPath.join(__dirname, './fixtures/onefile.lcov');
Expand Down
8 changes: 4 additions & 4 deletions test/sendToCoveralls.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const should = require('should');
const request = require('request');
const sinon = require('sinon-restore');
const sinon = require('sinon').sandbox.create();
const logDriver = require('log-driver');
const index = require('..');

Expand All @@ -15,7 +15,7 @@ describe('sendToCoveralls', () => {
});

afterEach(() => {
sinon.restoreAll();
sinon.restore();
if (realCoverallsHost !== undefined) {
process.env.COVERALLS_ENDPOINT = realCoverallsHost;
} else {
Expand All @@ -24,7 +24,7 @@ describe('sendToCoveralls', () => {
});

it('passes on the correct params to request.post', done => {
sinon.stub(request, 'post', (obj, cb) => {
sinon.stub(request, 'post').callsFake((obj, cb) => {
obj.url.should.equal('https://coveralls.io/api/v1/jobs');
obj.form.should.eql({ json: '{"some":"obj"}' });
cb('err', 'response', 'body');
Expand All @@ -42,7 +42,7 @@ describe('sendToCoveralls', () => {

it('allows sending to enterprise url', done => {
process.env.COVERALLS_ENDPOINT = 'https://coveralls-ubuntu.domain.com';
sinon.stub(request, 'post', (obj, cb) => {
sinon.stub(request, 'post').callsFake((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');
Expand Down

0 comments on commit eb6dc35

Please sign in to comment.