diff --git a/package.json b/package.json index 350287eb9..771be613a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/logger.js b/src/logger.js index f049c1003..30411a1df 100644 --- a/src/logger.js +++ b/src/logger.js @@ -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): void => apply('error', type, values), + log: (...values: Array): void => apply('log', type, values), + warn: (...values: Array): void => apply('warn', type, values) }; }; diff --git a/src/logger.spec.js b/src/logger.spec.js index d3e0be30a..e02141234 100644 --- a/src/logger.spec.js +++ b/src/logger.spec.js @@ -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 + ); }); }); diff --git a/yarn.lock b/yarn.lock index b52aa3c49..6277cc14f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"