-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.test.ts
27 lines (26 loc) · 1010 Bytes
/
logger.test.ts
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
import { Logger, setLogger } from '../src/service/logger';
describe('Tests Logger singleton', () => {
beforeEach(() => {
jest.clearAllMocks();
});
it('Should return default Logger instance if not provided anything', () => {
expect(Logger.Instance).toBeTruthy();
});
it("Should return what's passed in", () => {
const customLogger = { info: jest.fn() } as any;
Logger.Instance = customLogger;
expect(Logger.Instance).toEqual(customLogger);
});
it('Should return latest logger passed in', () => {
const customLogger = { info: jest.fn() } as any;
const customLogger1 = { info: jest.fn() } as any;
Logger.Instance = customLogger;
Logger.Instance = customLogger1;
expect(Logger.Instance).toEqual(customLogger1);
});
it('Should overwrite logger instance from Subscription Service', () => {
const customLogger = { info: jest.fn(), debug: jest.fn() } as any;
setLogger(customLogger);
expect(Logger.Instance).toStrictEqual(customLogger);
});
});