mirror of https://github.com/BTCPrivate/copay.git
add tests to log
This commit is contained in:
parent
ec58e90437
commit
43bd277959
|
@ -110,7 +110,7 @@ PublicKeyRing.fromObj = function(opts) {
|
|||
}
|
||||
|
||||
if (opts.cache && opts.cache.addressToPath) {
|
||||
log.info('PublicKeyRing: Using address cache');
|
||||
log.debug('PublicKeyRing: Using address cache');
|
||||
pkr.cache.addressToPath = opts.cache.addressToPath;
|
||||
pkr.rebuildCache();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
'use strict';
|
||||
var _ = require('lodash');
|
||||
var preconditions = require('preconditions').singleton();
|
||||
|
||||
function LocalStorage() {
|
||||
this.type = 'DB';
|
||||
|
||||
preconditions.checkState(typeof localStorage !== 'undefined',
|
||||
'localstorage not available, cannot run plugin');
|
||||
};
|
||||
|
||||
LocalStorage.prototype.init = function() {
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
var config = config || require('../../config');
|
||||
var _ = require('lodash');
|
||||
var ls;
|
||||
|
||||
var LS = require('../plugins/LocalStorage');
|
||||
var ls = new LS();
|
||||
|
||||
try {
|
||||
var LS = require('../plugins/LocalStorage');
|
||||
ls = new LS();
|
||||
} catch(e) {};
|
||||
|
||||
/**
|
||||
* @desc
|
||||
|
@ -122,9 +124,9 @@ Logger.prototype.setLevel = function(level) {
|
|||
var logger = new Logger('copay');
|
||||
var error = new Error();
|
||||
|
||||
var logLevel = config.logLevel;
|
||||
var logLevel = config.logLevel || 'info';
|
||||
|
||||
if (ls.getItem) {
|
||||
if (ls && ls.getItem) {
|
||||
ls.getItem("config", function(err, value) {
|
||||
if (err) return;
|
||||
var localConfig = JSON.parse(value);
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
'use strict';
|
||||
|
||||
var _ = require('lodash');
|
||||
var chai = chai || require('chai');
|
||||
var sinon = sinon || require('sinon');
|
||||
var should = chai.should();
|
||||
var log = require('../js/util/log');
|
||||
|
||||
describe.only('log utils', function() {
|
||||
afterEach(function() {
|
||||
log.setLevel('info');
|
||||
});
|
||||
|
||||
it('should log debug', function() {
|
||||
sinon.stub(console,'log');
|
||||
log.setLevel('debug');
|
||||
log.debug('hola');
|
||||
|
||||
var arg = console.log.getCall(0).args[0];
|
||||
arg.should.contain('util.log.js');
|
||||
arg.should.contain('hola');
|
||||
console.log.restore();
|
||||
});
|
||||
|
||||
it('should not log debug', function() {
|
||||
sinon.stub(console,'log');
|
||||
log.setLevel('info');
|
||||
log.debug('hola');
|
||||
console.log.called.should.equal(false);
|
||||
console.log.restore();
|
||||
});
|
||||
|
||||
it('should log debug', function() {
|
||||
log.getLevels().debug.should.equal(0);
|
||||
log.getLevels().fatal.should.equal(5);
|
||||
});
|
||||
|
||||
|
||||
});
|
Loading…
Reference in New Issue