Logger param type update (#48)

This commit is contained in:
Jaco Greeff
2017-12-14 09:29:42 +01:00
committed by GitHub
parent dda1586e60
commit 9fd345993e
4 changed files with 48 additions and 19 deletions
+1 -1
View File
@@ -30,7 +30,7 @@
},
"devDependencies": {
"@polkadot/api-jsonrpc": "^0.6.5",
"@polkadot/dev": "^0.13.3"
"@polkadot/dev": "^0.13.4"
},
"dependencies": {
"babel-runtime": "^6.26.0",
+3 -3
View File
@@ -28,8 +28,8 @@ module.exports = function logger (_type: string): Logger {
const type = ` ${_type.toUpperCase()}:`.slice(-16);
return {
error: (...values: any): void => apply('error', type, values),
log: (...values: any): void => apply('log', type, values),
warn: (...values: any): void => apply('warn', type, values)
error: (...values: Array<any>): void => apply('error', type, values),
log: (...values: Array<any>): void => apply('log', type, values),
warn: (...values: Array<any>): void => apply('warn', type, values)
};
};
+37 -8
View File
@@ -3,6 +3,8 @@
const { logger } = require('./index');
describe('logger', () => {
let dateMatch;
let prefixMatch;
let l;
let spy;
@@ -15,6 +17,9 @@ describe('logger', () => {
warn: jest.fn()
};
global.console = spy;
dateMatch = expect.stringMatching(/20[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/);
prefixMatch = expect.stringMatching(/TEST:/);
});
afterEach(() => {
@@ -24,18 +29,42 @@ describe('logger', () => {
it('logs to console.error with .error', () => {
l.error('console.error test');
expect(spy.error).toHaveBeenCalled();
});
it('logs to console.log with .log', () => {
l.log('console.log test');
expect(spy.log).toHaveBeenCalled();
expect(spy.error).toHaveBeenCalledWith(
dateMatch,
prefixMatch,
'console.error test'
);
});
it('logs to console.warn with .warn', () => {
l.warn('console.warn test');
expect(spy.warn).toHaveBeenCalled();
expect(spy.warn).toHaveBeenCalledWith(
dateMatch,
prefixMatch,
'console.warn test'
);
});
it('logs to console.log with .log', () => {
l.log('console.log test');
expect(spy.log).toHaveBeenCalledWith(
dateMatch,
prefixMatch,
'console.log test'
);
});
it('logs to with mulptiple values', () => {
l.log('test', 'a', 2);
expect(spy.log).toHaveBeenCalledWith(
dateMatch,
prefixMatch,
'test',
'a',
2
);
});
});
+7 -7
View File
@@ -60,9 +60,9 @@
dependencies:
babel-runtime "^6.26.0"
"@polkadot/dev@^0.13.3":
version "0.13.3"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.13.3.tgz#e90caf191134d233fb6321012914f951b8a3ec17"
"@polkadot/dev@^0.13.4":
version "0.13.4"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.13.4.tgz#beaa45da1655f8335b4a8294db3803f95cd3cc4e"
dependencies:
babel-cli "^6.26.0"
babel-core "^6.26.0"
@@ -86,7 +86,7 @@
eslint-plugin-promise "^3.6.0"
eslint-plugin-react "^7.4.0"
eslint-plugin-standard "^3.0.1"
flow-bin "^0.60.0"
flow-bin "^0.61.0"
flow-copy-source "^1.2.1"
jest "^21.2.1"
makeshift "^1.1.0"
@@ -1806,9 +1806,9 @@ flat-cache@^1.2.1:
graceful-fs "^4.1.2"
write "^0.2.1"
flow-bin@^0.60.0:
version "0.60.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.60.0.tgz#885d0d92a90f94c29445e0f9a0382f5b5debaaed"
flow-bin@^0.61.0:
version "0.61.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.61.0.tgz#d0473a8c35dbbf4de573823f4932124397d32d35"
flow-copy-source@^1.2.1:
version "1.2.1"