Skip to content

Commit

Permalink
Fix: Max log number
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Aug 27, 2016
1 parent 92a379b commit 1f937f3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Console/Logger.es6
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export default class Logger extends util.Emitter
this._lastLog = log;
}

if (this._maxNum !== 'infinite' && logs.length >= this._maxNum)
if (this._maxNum !== 'infinite' && logs.length > this._maxNum)
{
$el.find('li').first().remove();
logs.shift();
Expand Down
31 changes: 30 additions & 1 deletion test/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,33 @@ describe('filter', function ()

tool.filter('all');
});
});
});

describe('config', function ()
{
var config = tool.config;

it('max number', function ()
{
config.set('maxLogNum', '10');
tool.clear();
for (var i = 0; i < 20; i++) tool.log(i);
expect($tool.find('.eruda-log-item')).toHaveLength(10);
});

it('override console', function ()
{
config.set('overrideConsole', true);
console.clear();
console.log('test');
expect($tool.find('.eruda-log-item')).toContainText('test');
});

it('display extra info', function ()
{
config.set('displayExtraInfo', true);
tool.clear().log('test');
expect($tool.find('.eruda-logs li')).toContainElement('.eruda-header');
});
});

0 comments on commit 1f937f3

Please sign in to comment.