test(config) coverage: middle

This commit is contained in:
coderaiser 2017-12-07 14:15:03 +02:00
parent 81f4a207a7
commit aa707d9afb
2 changed files with 21 additions and 3 deletions

View file

@ -5,11 +5,14 @@ const path = require('path');
const test = require('tape');
const readjson = require('readjson');
const diff = require('sinon-called-with-diff');
const sinon = diff(require('sinon'));
const root = '../../';
const dir = root + 'server/';
const config = require(dir + 'config');
const {_cryptoPass} = config;
const {apiURL} = require(root + 'common/cloudfunc');
const pathHomeConfig = path.join(os.homedir(), '.cloudcmd.json');
const pathConfig = path.join(__dirname, '..', '..', 'json', 'config.json');
@ -106,3 +109,19 @@ test('config: cryptoPass', (t) => {
t.end();
});
test('config: middle: no', (t) => {
const {middle} = config;
const next = sinon.stub();
const res = null;
const url = `${apiURL}/config`;
const method = 'POST';
const req = {
url,
method
};
middle(req, res, next);
t.ok(next.calledWith(), 'should call next');
t.end();
});