@deploystack/docker-to-iac
Version:
Translate docker run and docker compose file to Infrastructure as Code
45 lines (44 loc) • 2.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const parseCommand_1 = require("../../../src/utils/parseCommand");
(0, vitest_1.describe)('parseCommand', () => {
(0, vitest_1.test)('should handle string command', () => {
const result = (0, parseCommand_1.parseCommand)('node server.js');
(0, vitest_1.expect)(result).toBe('node server.js');
});
(0, vitest_1.test)('should handle array command', () => {
const result = (0, parseCommand_1.parseCommand)(['node', 'server.js', '--port=3000']);
(0, vitest_1.expect)(result).toBe('node server.js --port=3000');
});
(0, vitest_1.test)('should handle empty string', () => {
const result = (0, parseCommand_1.parseCommand)('');
(0, vitest_1.expect)(result).toBe('');
});
(0, vitest_1.test)('should handle undefined', () => {
const result = (0, parseCommand_1.parseCommand)(undefined);
(0, vitest_1.expect)(result).toBe('');
});
(0, vitest_1.test)('should handle command with special characters', () => {
const result = (0, parseCommand_1.parseCommand)('sh -c "echo hello && npm start"');
(0, vitest_1.expect)(result).toBe('sh -c "echo hello && npm start"');
});
(0, vitest_1.test)('should handle array with empty elements', () => {
const result = (0, parseCommand_1.parseCommand)(['npm', 'start', '', 'ignored']);
(0, vitest_1.expect)(result).toBe('npm start ignored');
});
(0, vitest_1.test)('should handle array with mixed types', () => {
// This test ensures that the command handles non-string array elements
// by converting them to strings
const result = (0, parseCommand_1.parseCommand)(['npm', 'start', '--port=', 3000]);
(0, vitest_1.expect)(result).toBe('npm start --port= 3000');
});
(0, vitest_1.test)('should handle multi-line command string', () => {
const result = (0, parseCommand_1.parseCommand)(`npm start
--port=3000
--env=production`);
(0, vitest_1.expect)(result).toBe(`npm start
--port=3000
--env=production`);
});
});