/**
* Copyright Super iPaaS Integration LLC, an IBM Company 2024
*/
import { Components, Logger, LoggerConfig } from '@apic/studio-logger';
import { LogIntializer, LogWrapper } from '../../src/service/log-wrapper.js';

jest.mock('@apic/studio-logger', () => ({
	Logger: jest.fn().mockImplementation(() => ({
		logInfo: jest.fn(),
	})),
	LoggerBase: jest.fn().mockImplementation(() => ({
		logInfo: jest.fn(),
	})),
	Components: {
		DeployComponent: 'DeployComponent',
	},
	LoggerConfig: {
		isLoggerEnabled: jest.fn(),
	},
}));

describe('LogIntializer', () => {
	afterEach(() => {
		jest.clearAllMocks();
	});

	it('should initialize Logger and call logInfo if LoggerConfig is enabled', () => {
		(LoggerConfig.isLoggerEnabled as jest.Mock).mockReturnValue(true);

		new LogIntializer();

		expect(Logger).toHaveBeenCalledWith(Components.DeployComponent);
		expect(LogWrapper.logInfo).toHaveBeenCalledWith('0001', 'Deploy');
	});

	it('should not initialize Logger if LoggerConfig is not enabled', () => {
		(LoggerConfig.isLoggerEnabled as jest.Mock).mockReturnValue(false);

		new LogIntializer();

		expect(Logger).not.toHaveBeenCalled();
		expect(LogWrapper.logInfo).not.toHaveBeenCalledWith('0001', 'Deploy');
	});
});
