Skip to content

Commit

Permalink
Upgraded the deps and adjusted the tests to new Sinon's API.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Piechaczek committed May 11, 2018
1 parent 1c545fb commit 76fd6f9
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 101 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ const meow = require( 'meow' );
const mgit = require( './lib/index' );

const meowOptions = {
alias: {
v: 'version'
flags: {
version: {
alias: 'v'
}
}
};

Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@
],
"main": "index.js",
"dependencies": {
"chalk": "^2.3.0",
"chalk": "^2.4.1",
"cli-table": "^0.3.1",
"generic-pool": "^3.4.1",
"meow": "^4.0.0",
"generic-pool": "^3.4.2",
"meow": "^5.0.0",
"minimatch": "^3.0.4",
"shelljs": "^0.8.1",
"upath": "^1.0.4"
"shelljs": "^0.8.2",
"upath": "^1.0.5"
},
"devDependencies": {
"@ckeditor/ckeditor5-dev-env": "^8.0.5",
"@ckeditor/ckeditor5-dev-env": "^9.0.1",
"@ckeditor/ckeditor5-dev-lint": "^3.1.4",
"chai": "^4.1.2",
"eslint": "^4.17.0",
"eslint": "^4.19.1",
"eslint-config-ckeditor5": "^1.0.8",
"husky": "^0.14.3",
"istanbul": "^0.4.5",
"lint-staged": "^6.1.0",
"mocha": "^5.0.0",
"lint-staged": "^7.1.0",
"mocha": "^5.1.1",
"mockery": "^2.1.0",
"sinon": "^4.2.2"
"sinon": "^5.0.7"
},
"repository": {
"type": "git",
Expand Down
14 changes: 6 additions & 8 deletions tests/commands/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,22 @@ const mockery = require( 'mockery' );
const expect = require( 'chai' ).expect;

describe( 'commands/bootstrap', () => {
let bootstrapCommand, sandbox, stubs, data;
let bootstrapCommand, stubs, data;

beforeEach( () => {
sandbox = sinon.sandbox.create();

mockery.enable( {
useCleanCache: true,
warnOnReplace: false,
warnOnUnregistered: false
} );

stubs = {
exec: sandbox.stub(),
exec: sinon.stub(),
fs: {
existsSync: sandbox.stub( fs, 'existsSync' )
existsSync: sinon.stub( fs, 'existsSync' )
},
path: {
join: sandbox.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) )
join: sinon.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) )
}
};

Expand All @@ -54,7 +52,7 @@ describe( 'commands/bootstrap', () => {
} );

afterEach( () => {
sandbox.restore();
sinon.restore();
mockery.disable();
} );

Expand Down Expand Up @@ -140,7 +138,7 @@ describe( 'commands/bootstrap', () => {

describe( 'afterExecute()', () => {
it( 'informs about number of processed packages', () => {
const consoleLog = sandbox.stub( console, 'log' );
const consoleLog = sinon.stub( console, 'log' );

const processedPackages = new Set();
processedPackages.add( 'package-1' );
Expand Down
8 changes: 3 additions & 5 deletions tests/commands/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ const mockery = require( 'mockery' );
const expect = require( 'chai' ).expect;

describe( 'commands/checkout', () => {
let checkoutCommand, sandbox, stubs, data;
let checkoutCommand, stubs, data;

beforeEach( () => {
sandbox = sinon.sandbox.create();

mockery.enable( {
useCleanCache: true,
warnOnReplace: false,
Expand All @@ -25,7 +23,7 @@ describe( 'commands/checkout', () => {

stubs = {
execCommand: {
execute: sandbox.stub()
execute: sinon.stub()
}
};

Expand All @@ -41,7 +39,7 @@ describe( 'commands/checkout', () => {
} );

afterEach( () => {
sandbox.restore();
sinon.restore();
mockery.disable();
} );

Expand Down
10 changes: 4 additions & 6 deletions tests/commands/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ const mockery = require( 'mockery' );
const expect = require( 'chai' ).expect;

describe( 'commands/diff', () => {
let diffCommand, sandbox, stubs, data;
let diffCommand, stubs, data;

beforeEach( () => {
sandbox = sinon.sandbox.create();

mockery.enable( {
useCleanCache: true,
warnOnReplace: false,
Expand All @@ -25,7 +23,7 @@ describe( 'commands/diff', () => {

stubs = {
execCommand: {
execute: sandbox.stub()
execute: sinon.stub()
}
};

Expand All @@ -39,7 +37,7 @@ describe( 'commands/diff', () => {
} );

afterEach( () => {
sandbox.restore();
sinon.restore();
mockery.disable();
} );

Expand Down Expand Up @@ -125,7 +123,7 @@ describe( 'commands/diff', () => {

describe( 'afterExecute()', () => {
it( 'should describe what kind of logs are displayed', () => {
const logStub = sandbox.stub( console, 'log' );
const logStub = sinon.stub( console, 'log' );

diffCommand.afterExecute();

Expand Down
14 changes: 6 additions & 8 deletions tests/commands/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,25 @@ const mockery = require( 'mockery' );
const expect = require( 'chai' ).expect;

describe( 'commands/exec', () => {
let execCommand, sandbox, stubs, data;
let execCommand, stubs, data;

beforeEach( () => {
sandbox = sinon.sandbox.create();

mockery.enable( {
useCleanCache: true,
warnOnReplace: false,
warnOnUnregistered: false
} );

stubs = {
exec: sandbox.stub(),
exec: sinon.stub(),
fs: {
existsSync: sandbox.stub( fs, 'existsSync' )
existsSync: sinon.stub( fs, 'existsSync' )
},
path: {
join: sandbox.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) )
join: sinon.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) )
},
process: {
chdir: sandbox.stub( process, 'chdir' )
chdir: sinon.stub( process, 'chdir' )
}
};

Expand All @@ -57,7 +55,7 @@ describe( 'commands/exec', () => {
} );

afterEach( () => {
sandbox.restore();
sinon.restore();
mockery.disable();
} );

Expand Down
10 changes: 4 additions & 6 deletions tests/commands/savehashes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ const mockery = require( 'mockery' );
const expect = require( 'chai' ).expect;

describe( 'commands/savehashes', () => {
let saveHashesCommand, sandbox, stubs, data, mgitJsonPath, updateFunction;
let saveHashesCommand, stubs, data, mgitJsonPath, updateFunction;

beforeEach( () => {
sandbox = sinon.sandbox.create();

mockery.enable( {
useCleanCache: true,
warnOnReplace: false,
Expand All @@ -26,10 +24,10 @@ describe( 'commands/savehashes', () => {

stubs = {
execCommand: {
execute: sandbox.stub()
execute: sinon.stub()
},
path: {
join: sandbox.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) )
join: sinon.stub( path, 'join' ).callsFake( ( ...chunks ) => chunks.join( '/' ) )
}
};

Expand All @@ -50,7 +48,7 @@ describe( 'commands/savehashes', () => {
} );

afterEach( () => {
sandbox.restore();
sinon.restore();
mockery.disable();
} );

Expand Down
46 changes: 22 additions & 24 deletions tests/commands/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,33 @@ const mockery = require( 'mockery' );
const expect = require( 'chai' ).expect;

describe( 'commands/status', () => {
let statusCommand, sandbox, stubs, data;
let statusCommand, stubs, data;

beforeEach( () => {
sandbox = sinon.sandbox.create();

mockery.enable( {
useCleanCache: true,
warnOnReplace: false,
warnOnUnregistered: false
} );

stubs = {
gitStatusParser: sandbox.stub(),
gitStatusParser: sinon.stub(),
execCommand: {
execute: sandbox.stub()
execute: sinon.stub()
},
table: {
constructor: sandbox.stub(),
push: sandbox.stub(),
toString: sandbox.stub()
constructor: sinon.stub(),
push: sinon.stub(),
toString: sinon.stub()
},
chalk: {
cyan: sandbox.stub(),
bold: sandbox.stub(),
yellow: sandbox.stub(),
green: sandbox.stub(),
red: sandbox.stub(),
blue: sandbox.stub(),
magenta: sandbox.stub(),
cyan: sinon.stub(),
bold: sinon.stub(),
yellow: sinon.stub(),
green: sinon.stub(),
red: sinon.stub(),
blue: sinon.stub(),
magenta: sinon.stub(),
}
};

Expand Down Expand Up @@ -89,13 +87,13 @@ describe( 'commands/status', () => {
} );

afterEach( () => {
sandbox.restore();
sinon.restore();
mockery.disable();
} );

describe( 'beforeExecute()', () => {
it( 'should describe why logs are not display in "real-time"', () => {
const logStub = sandbox.stub( console, 'log' );
const logStub = sinon.stub( console, 'log' );

statusCommand.beforeExecute();

Expand Down Expand Up @@ -198,7 +196,7 @@ describe( 'commands/status', () => {

describe( 'afterExecute()', () => {
it( 'do not display anything if processed packages list is empty', () => {
const logStub = sandbox.stub( console, 'log' );
const logStub = sinon.stub( console, 'log' );

const processedPackages = new Set();
const commandResponses = new Set();
Expand All @@ -212,7 +210,7 @@ describe( 'commands/status', () => {
} );

it( 'do not display anything if command responses list is empty', () => {
const logStub = sandbox.stub( console, 'log' );
const logStub = sinon.stub( console, 'log' );

const processedPackages = new Set();
const commandResponses = new Set();
Expand All @@ -226,7 +224,7 @@ describe( 'commands/status', () => {
} );

it( 'draws the table with statuses of the repositories', () => {
const logStub = sandbox.stub( console, 'log' );
const logStub = sinon.stub( console, 'log' );

const processedPackages = new Set();
const commandResponses = new Set();
Expand Down Expand Up @@ -291,7 +289,7 @@ describe( 'commands/status', () => {
} );

it( 'highlights a row if current branch is other than master', () => {
const logStub = sandbox.stub( console, 'log' );
const logStub = sinon.stub( console, 'log' );

const processedPackages = new Set();
const commandResponses = new Set();
Expand Down Expand Up @@ -319,7 +317,7 @@ describe( 'commands/status', () => {
} );

it( 'does not highlight a row if current branch is equal to master', () => {
const logStub = sandbox.stub( console, 'log' );
const logStub = sinon.stub( console, 'log' );

const processedPackages = new Set();
const commandResponses = new Set();
Expand Down Expand Up @@ -347,7 +345,7 @@ describe( 'commands/status', () => {
} );

it( 'adds "!" before the branch name if current branch is other than defined in "mgit.json"', () => {
const logStub = sandbox.stub( console, 'log' );
const logStub = sinon.stub( console, 'log' );

const processedPackages = new Set();
const commandResponses = new Set();
Expand Down Expand Up @@ -381,7 +379,7 @@ describe( 'commands/status', () => {
} );

it( 'sorts packages by alphabetically', () => {
const logStub = sandbox.stub( console, 'log' );
const logStub = sinon.stub( console, 'log' );

const processedPackages = new Set();
const commandResponses = new Set();
Expand Down

0 comments on commit 76fd6f9

Please sign in to comment.