Skip to content

Commit eb6dc35

Browse files
XhmikosRguimard
andauthoredApr 24, 2020
Update sinon to v7.5.0. (#288)
Co-authored-by: Xavier <yadd@debian.org>
1 parent 844d765 commit eb6dc35

File tree

4 files changed

+132
-46
lines changed

4 files changed

+132
-46
lines changed
 

‎package-lock.json

+116-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"nyc": "^14.1.1",
4747
"should": "^9.0.2",
4848
"shx": "^0.3.2",
49-
"sinon-restore": "^1.0.1"
49+
"sinon": "^7.5.0"
5050
},
5151
"engines": {
5252
"node": ">=6"

‎test/handleInput.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
const fs = require('fs');
44
const sysPath = require('path');
55
const should = require('should');
6-
const sinon = require('sinon-restore');
6+
const sinon = require('sinon').sandbox.create();
77
const logDriver = require('log-driver');
88
const index = require('..');
99

1010
logDriver({ level: false });
1111

1212
describe('handleInput', () => {
1313
afterEach(() => {
14-
sinon.restoreAll();
14+
sinon.restore();
1515
});
1616
it('returns an error when there\'s an error getting options', done => {
17-
sinon.stub(index, 'getOptions', cb => cb('some error', {}));
17+
sinon.stub(index, 'getOptions').callsFake(cb => cb('some error', {}));
1818
const path = sysPath.join(__dirname, './fixtures/onefile.lcov');
1919
const input = fs.readFileSync(path, 'utf8');
2020
index.handleInput(input, err => {
@@ -23,8 +23,8 @@ describe('handleInput', () => {
2323
});
2424
});
2525
it('returns an error when there\'s an error converting', done => {
26-
sinon.stub(index, 'getOptions', cb => cb(null, {}));
27-
sinon.stub(index, 'convertLcovToCoveralls', (input, options, cb) => {
26+
sinon.stub(index, 'getOptions').callsFake(cb => cb(null, {}));
27+
sinon.stub(index, 'convertLcovToCoveralls').callsFake((input, options, cb) => {
2828
cb('some error');
2929
});
3030
const path = sysPath.join(__dirname, './fixtures/onefile.lcov');
@@ -35,8 +35,8 @@ describe('handleInput', () => {
3535
});
3636
});
3737
it('returns an error when there\'s an error sending', done => {
38-
sinon.stub(index, 'getOptions', cb => cb(null, {}));
39-
sinon.stub(index, 'sendToCoveralls', (postData, cb) => {
38+
sinon.stub(index, 'getOptions').callsFake(cb => cb(null, {}));
39+
sinon.stub(index, 'sendToCoveralls').callsFake((postData, cb) => {
4040
cb('some error');
4141
});
4242
const path = sysPath.join(__dirname, './fixtures/onefile.lcov');
@@ -47,8 +47,8 @@ describe('handleInput', () => {
4747
});
4848
});
4949
it('returns an error when there\'s a bad status code', done => {
50-
sinon.stub(index, 'getOptions', cb => cb(null, {}));
51-
sinon.stub(index, 'sendToCoveralls', (postData, cb) => {
50+
sinon.stub(index, 'getOptions').callsFake(cb => cb(null, {}));
51+
sinon.stub(index, 'sendToCoveralls').callsFake((postData, cb) => {
5252
cb(null, { statusCode: 500 }, 'body');
5353
});
5454
const path = sysPath.join(__dirname, './fixtures/onefile.lcov');
@@ -59,8 +59,8 @@ describe('handleInput', () => {
5959
});
6060
});
6161
it('completes successfully when there are no errors', done => {
62-
sinon.stub(index, 'getOptions', cb => cb(null, {}));
63-
sinon.stub(index, 'sendToCoveralls', (postData, cb) => {
62+
sinon.stub(index, 'getOptions').callsFake(cb => cb(null, {}));
63+
sinon.stub(index, 'sendToCoveralls').callsFake((postData, cb) => {
6464
cb(null, { statusCode: 200 }, 'body');
6565
});
6666
const path = sysPath.join(__dirname, './fixtures/onefile.lcov');

‎test/sendToCoveralls.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const should = require('should');
44
const request = require('request');
5-
const sinon = require('sinon-restore');
5+
const sinon = require('sinon').sandbox.create();
66
const logDriver = require('log-driver');
77
const index = require('..');
88

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

1717
afterEach(() => {
18-
sinon.restoreAll();
18+
sinon.restore();
1919
if (realCoverallsHost !== undefined) {
2020
process.env.COVERALLS_ENDPOINT = realCoverallsHost;
2121
} else {
@@ -24,7 +24,7 @@ describe('sendToCoveralls', () => {
2424
});
2525

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

4343
it('allows sending to enterprise url', done => {
4444
process.env.COVERALLS_ENDPOINT = 'https://coveralls-ubuntu.domain.com';
45-
sinon.stub(request, 'post', (obj, cb) => {
45+
sinon.stub(request, 'post').callsFake((obj, cb) => {
4646
obj.url.should.equal('https://coveralls-ubuntu.domain.com/api/v1/jobs');
4747
obj.form.should.eql({ json: '{"some":"obj"}' });
4848
cb('err', 'response', 'body');

0 commit comments

Comments
 (0)
Please sign in to comment.