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'); + }); });