mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
feature(util) getStrBigFirst: client -> util
This commit is contained in:
parent
f1af8a76e5
commit
7036cb8ea2
3 changed files with 23 additions and 16 deletions
|
|
@ -43,6 +43,8 @@ var Util, DOM, CloudFunc, join;
|
|||
Debug = false;
|
||||
};
|
||||
|
||||
var getStrBigFirst = Util.getStrBigFirst;
|
||||
|
||||
/**
|
||||
* Функция привязываеться ко всем ссылкам и
|
||||
* загружает содержимое каталогов
|
||||
|
|
@ -552,18 +554,5 @@ var Util, DOM, CloudFunc, join;
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
function getStrBigFirst(str) {
|
||||
var first;
|
||||
|
||||
if (!str)
|
||||
throw Error('str could not be empty!');
|
||||
|
||||
first = str[0].toUpperCase();
|
||||
str = first + str.slice(1);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
})(this, Util, DOM, CloudFunc);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,15 @@
|
|||
function UtilProto(exec) {
|
||||
var Util = this;
|
||||
|
||||
this.check = new checkProto();
|
||||
this.check = new checkProto();
|
||||
|
||||
this.getStrBigFirst = function getStrBigFirst(str) {
|
||||
if (!str)
|
||||
throw Error('str could not be empty!');
|
||||
|
||||
var first = str[0].toUpperCase();
|
||||
return first + str.slice(1);
|
||||
}
|
||||
|
||||
function checkProto() {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ const test = require('tape');
|
|||
const DIR = '../../';
|
||||
const Util = require(DIR + 'common/util');
|
||||
|
||||
test('getExt: no extension', function(t) {
|
||||
test('getExt: no extension', (t) => {
|
||||
const EXT = '';
|
||||
const name = 'file-withot-extension';
|
||||
const ext = Util.getExt(name);
|
||||
|
|
@ -13,7 +13,7 @@ test('getExt: no extension', function(t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('getExt: return extension', function(t) {
|
||||
test('getExt: return extension', (t) => {
|
||||
const EXT = '.png';
|
||||
const name = 'picture.png';
|
||||
const ext = Util.getExt(name);
|
||||
|
|
@ -22,3 +22,13 @@ test('getExt: return extension', function(t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('getStrBigFirst: args', (t) => {
|
||||
t.throws(Util.getStrBigFirst, /str could not be empty!/, 'should throw when no str');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('getStrBigFirst', (t) => {
|
||||
t.equal(Util.getStrBigFirst('hello'), 'Hello', 'should return str');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue