

// Mock the dependencies
import {satisfies} from 'semver';
import {validateNodeVersion} from './version-validator.js';
import {showWarning} from '../helpers/common/message-helper.js';

jest.mock('semver', () => ({
	satisfies: jest.fn(),
}));

jest.mock('../helpers/common/message-helper', () => ({
	showWarning: jest.fn(),
}));

describe('validateNodeVersion', () => {


	it('should not show a warning when the node version is supported', () => {
		// Set up the mock implementation
		(satisfies as jest.Mock).mockReturnValue(true); // Mock satisfies to return false

		// Call the function
		validateNodeVersion('v24.7.0');

		// Assert that showWarning was called with the correct arguments
		expect(showWarning).not.toHaveBeenCalled();
	});

	it('should show a warning when the node version is unsupported', () => {
		// Set up the mock implementation
		(satisfies as jest.Mock).mockReturnValue(false); // Mock satisfies to return false

		// Call the function
		validateNodeVersion('v14.0.0');

		// Assert that showWarning was called with the correct arguments
		expect(showWarning).toHaveBeenCalledWith(
			'[WARNING]: Using unsupported node version - v14.0.0. Supported node version is "^24.7.0". Some of the features may not be working as expected.'
		);
	});


});
