-
Notifications
You must be signed in to change notification settings - Fork 278
Expand file tree
/
Copy pathlogger.test.ts
More file actions
48 lines (39 loc) · 1.28 KB
/
logger.test.ts
File metadata and controls
48 lines (39 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { _console, logger } from '../logger';
beforeEach(() => {
jest.spyOn(_console, 'debug').mockImplementation(() => {});
jest.spyOn(_console, 'info').mockImplementation(() => {});
jest.spyOn(_console, 'warn').mockImplementation(() => {});
jest.spyOn(_console, 'error').mockImplementation(() => {});
});
test('debug should call console.debug', () => {
logger.debug('test message');
expect(_console.debug).toHaveBeenCalledTimes(1);
expect(jest.mocked(_console.debug).mock.calls[0][0]).toMatchInlineSnapshot(`
" ● test message
"
`);
});
test('should call console.info', () => {
logger.info('info message');
expect(_console.info).toHaveBeenCalledTimes(1);
expect(jest.mocked(_console.info).mock.calls[0][0]).toMatchInlineSnapshot(`
" ● info message
"
`);
});
test('should call console.warn', () => {
logger.warn('warning message');
expect(_console.warn).toHaveBeenCalledTimes(1);
expect(jest.mocked(_console.warn).mock.calls[0][0]).toMatchInlineSnapshot(`
" ▲ warning message
"
`);
});
test('should call console.error', () => {
logger.error('error message');
expect(_console.error).toHaveBeenCalledTimes(1);
expect(jest.mocked(_console.error).mock.calls[0][0]).toMatchInlineSnapshot(`
" ■ error message
"
`);
});