From aadc79e4302f2d94c3de8ec8eade59cb0045d408 Mon Sep 17 00:00:00 2001 From: Dante Lex Date: Tue, 8 Aug 2023 17:01:28 +0100 Subject: [PATCH 1/3] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 56adb93..c6f3130 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ yarn add @onboardbase/secure-log # npm i @onboardbase/secure-log ## Usage Import the SecureLog library at the top level of your project. +**Note**: If you are using any env library (e.g. dotenv) in your project, you should import those first before importing SecureLog. ```js import SecureLog from '@onboardbase/secure-log'; @@ -40,7 +41,7 @@ The SecureLog Library also accepts an object. ```js export default interface IOptions { disableOn?: 'development' | 'production'; // You can use this to specify if you want the SecureLog library to be disabled in a specific environment - disableConsoleOn?: 'development' | 'production'; // You can use this to disable console entirely in a specific environment + disableConsoleOn?: 'development' | 'production'; // You can use this to disable the console entirely in a specific environment } ``` From c79de6405b19351b762e306ebf54502e50a040ff Mon Sep 17 00:00:00 2001 From: Dante Lex Date: Tue, 8 Aug 2023 17:03:54 +0100 Subject: [PATCH 2/3] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index c6f3130..2b22a01 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,7 @@ yarn add @onboardbase/secure-log # npm i @onboardbase/secure-log ## Usage -Import the SecureLog library at the top level of your project. -**Note**: If you are using any env library (e.g. dotenv) in your project, you should import those first before importing SecureLog. +Import the SecureLog library at the top level of your project. If you use any env/secret library (e.g. dotenv) in your project, you should import those before importing SecureLog. ```js import SecureLog from '@onboardbase/secure-log'; From 9195ba26449caad29ba4bb867333aba7051049d6 Mon Sep 17 00:00:00 2001 From: Aleem Isiaka Date: Tue, 15 Aug 2023 10:47:38 +0100 Subject: [PATCH 3/3] Tests for errors and warnings --- test/log.test.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/log.test.ts b/test/log.test.ts index ba19534..42f0b19 100644 --- a/test/log.test.ts +++ b/test/log.test.ts @@ -3,7 +3,10 @@ const Log = require('../dist'); const mockedLog = jest.fn(); const mockConsoleLog = () => { + mockedLog.mockReset(); console.log = mockedLog; + console.warn = mockedLog; + console.error = mockedLog; }; let secureLog; @@ -13,7 +16,7 @@ const setup = (options = {}) => { }; describe('Test console.log', () => { - beforeAll(() => { + beforeEach(() => { setup(); }); it('should have called console.log with hello', () => { @@ -24,4 +27,14 @@ describe('Test console.log', () => { 'hello' ); }); + + it('should have called console.warn with hello warn', () => { + secureLog.warn('hello warn'); + expect(mockedLog).toHaveBeenCalledWith('hello warn'); + }); + + it('should have called console.error with hello error', () => { + secureLog.error('hello error'); + expect(mockedLog).toHaveBeenCalledWith('hello error'); + }); });