Skip to content

Commit

Permalink
Tests for errors and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
limistah committed Aug 15, 2023
1 parent c79de64 commit 9195ba2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/log.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -13,7 +16,7 @@ const setup = (options = {}) => {
};

describe('Test console.log', () => {
beforeAll(() => {
beforeEach(() => {
setup();
});
it('should have called console.log with hello', () => {
Expand All @@ -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');
});
});

0 comments on commit 9195ba2

Please sign in to comment.