mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
refactor(cloudfunc) formatMsg: name default value
This commit is contained in:
parent
99d8487b29
commit
cf36456303
2 changed files with 23 additions and 2 deletions
|
|
@ -21,11 +21,10 @@ module.exports.Entity = Entity;
|
|||
|
||||
module.exports.formatMsg = (msg, name, status) => {
|
||||
status = status || 'ok';
|
||||
name = name || '';
|
||||
|
||||
if (name)
|
||||
name = '("' + name + '")';
|
||||
else
|
||||
name = '';
|
||||
|
||||
return msg + ': ' + status + name;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -122,3 +122,25 @@ test('render', (t) => {
|
|||
});
|
||||
});
|
||||
|
||||
test('cloudfunc: formatMsg', (t) => {
|
||||
const msg = 'hello';
|
||||
const name = 'name';
|
||||
const status = 'ok';
|
||||
|
||||
const result = CloudFunc.formatMsg(msg, name, status);
|
||||
|
||||
t.equal(result, 'hello: ok("name")');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudfunc: formatMsg', (t) => {
|
||||
const msg = 'hello';
|
||||
const name = null;
|
||||
const status = 'ok';
|
||||
|
||||
const result = CloudFunc.formatMsg(msg, name, status);
|
||||
|
||||
t.equal(result, 'hello: ok');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue