sda
Version:
Software development assistant
116 lines • 4.64 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Log_1 = __importDefault(require("../Log"));
const replaceConfigWithAbsolutePaths_1 = __importDefault(require("./replaceConfigWithAbsolutePaths"));
const path = 'C:\\A\\B\\C\\sdaconfig.json';
beforeAll(() => {
Log_1.default.isEnabled = false;
});
describe('environment paths', () => {
test('replace environment with relative path', () => {
const config = {
environments: {
test: {
templateId: 'testTemplate',
path: '..'
}
}
};
const result = replaceConfigWithAbsolutePaths_1.default(config, path);
expect(result.environments).toBeDefined();
expect(result.environments).toHaveProperty('test');
expect(result.environments.test.path).toBe('C:\\A\\B');
});
test('replace environment with absolute path', () => {
const config = {
environments: {
test: {
templateId: 'testTemplate',
path: 'D:\\TEST'
}
}
};
const result = replaceConfigWithAbsolutePaths_1.default(config, path);
expect(result.environments).toBeDefined();
expect(result.environments).toHaveProperty('test');
expect(result.environments.test.path).toBe('D:\\TEST');
});
});
describe('commands with filepath', () => {
test('replace command filepath with relative path', () => {
const config = {
templates: {
test: {
commands: {
testCmd: {
filePath: '../test_script'
}
}
}
}
};
const result = replaceConfigWithAbsolutePaths_1.default(config, path);
expect(result.templates).toBeDefined();
expect(result.templates).toHaveProperty('test');
expect(result.templates.test.commands).toHaveProperty('testCmd');
expect(result.templates.test.commands.testCmd).toHaveProperty('filePath');
expect(result.templates.test.commands.testCmd.filePath).toBe('C:\\A\\B\\test_script');
});
test('replace command cwd with absolute path', () => {
const config = {
templates: {
test: {
commands: {
testCmd: {
filePath: 'D:\\test_script'
}
}
}
}
};
const result = replaceConfigWithAbsolutePaths_1.default(config, path);
expect(result.templates).toBeDefined();
expect(result.templates).toHaveProperty('test');
expect(result.templates.test.commands).toHaveProperty('testCmd');
expect(result.templates.test.commands.testCmd).toHaveProperty('filePath');
expect(result.templates.test.commands.testCmd.filePath).toBe('D:\\test_script');
});
});
describe('other commands', () => {
test('does nothing with string commands', () => {
const config = {
templates: {
test: {
commands: {
testCmd: 'echo TEST'
}
}
}
};
const result = replaceConfigWithAbsolutePaths_1.default(config, path);
expect(result.templates).toBeDefined();
expect(result.templates).toHaveProperty('test');
expect(result.templates.test.commands).toHaveProperty('testCmd');
expect(result.templates.test.commands.testCmd).toBe('echo TEST');
});
test('does nothing with array commands', () => {
const config = {
templates: {
test: {
commands: {
testCmd: ['echo TEST', 'echo ANOTHER TEST']
}
}
}
};
const result = replaceConfigWithAbsolutePaths_1.default(config, path);
expect(result.templates).toBeDefined();
expect(result.templates).toHaveProperty('test');
expect(result.templates.test.commands).toHaveProperty('testCmd');
expect(result.templates.test.commands.testCmd).toHaveLength(2);
});
});
//# sourceMappingURL=replaceConfigWithAbsolutePaths.test.js.map