Skip to content

Commit

Permalink
Fixed "if" condition in "status/afterExecute()".
Browse files Browse the repository at this point in the history
  • Loading branch information
pomek committed Jul 15, 2019
1 parent 3a32601 commit dd54171
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/commands/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ module.exports = {
statusColumn.push( color( 'green', `+${ status.staged.length }` ) );
}

if ( status.modified.length ) {
if ( modifiedFiles ) {
statusColumn.push( color( 'red', `M${ modifiedFiles }` ) );
}

Expand Down
48 changes: 48 additions & 0 deletions tests/commands/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,5 +531,53 @@ describe( 'commands/status', () => {

logStub.restore();
} );

it( 'counts unmerged files as modified even if number of modified files is equal 0', () => {
const logStub = sinon.stub( console, 'log' );

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

processedPackages.add( '@ckeditor/ckeditor5-foo' );

commandResponses.add( {
packageName: 'foo',
status: {
branch: 'master',
ahead: 0,
behind: 2,
staged: [],
modified: [],
untracked: [],
unmerged: [ '.travis.yml' ]
},
mgitBranch: 'master',
commit: 'abcd123'
} );

stubs.table.toString.returns( '┻━┻' );

statusCommand.afterExecute( processedPackages, commandResponses );

expect( stubs.table.constructor.firstCall.args[ 0 ] ).to.deep.equal( {
head: [ 'Package', 'Branch', 'Commit', 'Status' ],
style: {
compact: true
}
} );

expect( stubs.table.push.firstCall.args[ 0 ] ).to.deep.equal(
[ 'foo', 'master ↓2', 'abcd123', 'M1' ]
);

expect( stubs.table.toString.calledOnce ).to.equal( true );

expect( logStub.calledTwice ).to.equal( true );
expect( logStub.firstCall.args[ 0 ] ).to.equal( '┻━┻' );
expect( logStub.secondCall.args[ 0 ] ).to.match( /^Legend:/ );
expect( stubs.chalk.cyan.calledOnce ).to.equal( true );

logStub.restore();
} );
} );
} );

0 comments on commit dd54171

Please sign in to comment.