Fix: Max log number

This commit is contained in:
surunzi
2016-08-27 19:00:42 +08:00
parent 92a379b4cc
commit 1f937f3941
2 changed files with 31 additions and 2 deletions

View File

@@ -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();

View File

@@ -196,3 +196,32 @@ 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');
});
});