mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
test(cloudcmd) getPrefix
This commit is contained in:
parent
10255164d5
commit
016b5c79f9
2 changed files with 22 additions and 8 deletions
|
|
@ -41,13 +41,6 @@ const clean = (a) => a.filter(notEmpty);
|
|||
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
|
||||
function getPrefix(prefix) {
|
||||
if (typeof prefix === 'function')
|
||||
return prefix() || '';
|
||||
|
||||
return prefix || '';
|
||||
}
|
||||
|
||||
module.exports = (params) => {
|
||||
const p = params || {};
|
||||
const options = p.config || {};
|
||||
|
|
@ -99,6 +92,15 @@ function defaultValue(name, options) {
|
|||
return value;
|
||||
}
|
||||
|
||||
module.exports._getPrefix = getPrefix;
|
||||
function getPrefix(prefix) {
|
||||
if (typeof prefix === 'function')
|
||||
return prefix() || '';
|
||||
|
||||
return prefix || '';
|
||||
}
|
||||
|
||||
|
||||
function authCheck(socket, success) {
|
||||
if (!config('auth'))
|
||||
return success();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@ const currify = require('currify');
|
|||
const DIR = '../../server/';
|
||||
const cloudcmd = require(DIR + 'cloudcmd');
|
||||
const config = require(DIR + 'config');
|
||||
const {_authenticate} = cloudcmd;
|
||||
const {
|
||||
_authenticate,
|
||||
_getPrefix,
|
||||
} = cloudcmd;
|
||||
|
||||
test('cloudcmd: args: no', (t) => {
|
||||
const fn = () => cloudcmd();
|
||||
|
|
@ -49,6 +52,15 @@ test('cloudcmd: defaults: console', (t) => {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: getPrefix', (t) => {
|
||||
const value = 'hello';
|
||||
const fn = () => value;
|
||||
const result = _getPrefix(fn);
|
||||
|
||||
t.equal(result, value, 'should equal')
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: authenticate: reject', (t) => {
|
||||
const success = sinon.stub();
|
||||
const emit = sinon.stub();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue