Commit 2ac8cec6 authored by Erik Schwartz's avatar Erik Schwartz 🉐
Browse files

Expand unit tests

parent 574f8e83
......@@ -7,24 +7,40 @@
// --------------------------------------------------------------------------
const assert = require('assert');
const fs = require('fs');
const rewire = require('rewire');
const pf = rewire('../functions');
// Map rewired, private functions to friendlier names
const readSftpOptions = pf.__get__('readSftpOptions');
const liveConf = './site-config/client.json';
const exampleConf = liveConf + '.EXAMPLE';
// --------------------------------------------------------------------------
// MOCHA TESTS
// --------------------------------------------------------------------------
describe('Filesystem & JSON parsing integration', function() {
let inFile = './site-config/client.json.EXAMPLE';
describe('Read ' + inFile, function() {
it('should return object with known properties', function() {
let o = readSftpOptions(inFile);
assert.equal(typeof o, 'object');
assert.equal(o.hasOwnProperty('remoteSettings'), true);
assert.equal(o.hasOwnProperty('localFile'), true);
let configs = [exampleConf];
if (fs.existsSync(liveConf)) {
configs.push(liveConf);
}
for (let i = 0; i < configs.length; i++) {
let o;
describe('Read ' + configs[i], function() {
it('should return an object', function() {
o = readSftpOptions(configs[i]);
});
});
describe('Check names', function() {
it('should contain known properties', function() {
assert.equal(o.hasOwnProperty('sshSettings'), true);
assert.equal(o.sshSettings.hasOwnProperty('host'), true);
assert.equal(o.sshSettings.hasOwnProperty('username'), true);
assert.equal(o.hasOwnProperty('localFile'), true);
assert.equal(o.hasOwnProperty('remoteFile'), true);
});
});
});
}
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment