3
3
const fs = require ( 'fs' ) ;
4
4
const sysPath = require ( 'path' ) ;
5
5
const should = require ( 'should' ) ;
6
- const sinon = require ( 'sinon-restore' ) ;
6
+ const sinon = require ( 'sinon' ) . sandbox . create ( ) ;
7
7
const logDriver = require ( 'log-driver' ) ;
8
8
const index = require ( '..' ) ;
9
9
10
10
logDriver ( { level : false } ) ;
11
11
12
12
describe ( 'handleInput' , ( ) => {
13
13
afterEach ( ( ) => {
14
- sinon . restoreAll ( ) ;
14
+ sinon . restore ( ) ;
15
15
} ) ;
16
16
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' , { } ) ) ;
18
18
const path = sysPath . join ( __dirname , './fixtures/onefile.lcov' ) ;
19
19
const input = fs . readFileSync ( path , 'utf8' ) ;
20
20
index . handleInput ( input , err => {
@@ -23,8 +23,8 @@ describe('handleInput', () => {
23
23
} ) ;
24
24
} ) ;
25
25
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 ) => {
28
28
cb ( 'some error' ) ;
29
29
} ) ;
30
30
const path = sysPath . join ( __dirname , './fixtures/onefile.lcov' ) ;
@@ -35,8 +35,8 @@ describe('handleInput', () => {
35
35
} ) ;
36
36
} ) ;
37
37
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 ) => {
40
40
cb ( 'some error' ) ;
41
41
} ) ;
42
42
const path = sysPath . join ( __dirname , './fixtures/onefile.lcov' ) ;
@@ -47,8 +47,8 @@ describe('handleInput', () => {
47
47
} ) ;
48
48
} ) ;
49
49
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 ) => {
52
52
cb ( null , { statusCode : 500 } , 'body' ) ;
53
53
} ) ;
54
54
const path = sysPath . join ( __dirname , './fixtures/onefile.lcov' ) ;
@@ -59,8 +59,8 @@ describe('handleInput', () => {
59
59
} ) ;
60
60
} ) ;
61
61
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 ) => {
64
64
cb ( null , { statusCode : 200 } , 'body' ) ;
65
65
} ) ;
66
66
const path = sysPath . join ( __dirname , './fixtures/onefile.lcov' ) ;
0 commit comments