diff --git a/README.md b/README.md index 56adb93..2b22a01 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ yarn add @onboardbase/secure-log # npm i @onboardbase/secure-log ## Usage -Import the SecureLog library at the top level of your project. +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'; @@ -40,7 +40,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 } ``` 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'); + }); });