init commit

This commit is contained in:
Slawomir Jaranowski
2019-10-01 22:14:15 +02:00
commit 67c2286c8f
13 changed files with 5926 additions and 0 deletions

42
index.test.js Normal file
View File

@ -0,0 +1,42 @@
const process = require('process');
const cp = require('child_process');
const path = require('path');
const fs = require('fs');
const testHomePath = path.join(__dirname, 'temp');
const settingsPath = path.join(testHomePath, '.m2', 'settings.xml');
const indexPath = path.join(__dirname, 'index.js');
beforeAll(() => {
if (!fs.existsSync(testHomePath)) {
fs.mkdirSync(testHomePath);
}
process.env['HOME'] = testHomePath;
});
afterEach(() => {
try {
fs.unlinkSync(settingsPath);
} catch (error) {
console.error(error.message);
}
});
afterAll(() => {
try {
fs.rmdirSync(path.join(testHomePath, ".m2"));
fs.rmdirSync(testHomePath);
} catch (error) {
console.error(error.message);
}
});
test('run with default values', () => {
console.log(cp.execSync(`node ${indexPath}`, { env: process.env }).toString());
const settingsStatus = fs.lstatSync(settingsPath);
expect(settingsStatus.isFile()).toBeTruthy();
expect(settingsStatus.size).toBeGreaterThan(0);
})