mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 01:17:18 +00:00
fixed tests
This commit is contained in:
parent
a79303c817
commit
1a3ce4576d
10 changed files with 88 additions and 65 deletions
|
|
@ -1,4 +1,4 @@
|
|||
var CloudCommander, $, Util, DOM, CloudFunc;
|
||||
var CloudCommander, Util, DOM, CloudFunc;
|
||||
|
||||
(function(){
|
||||
"use strict";
|
||||
|
|
@ -15,6 +15,8 @@ var CloudCommander, $, Util, DOM, CloudFunc;
|
|||
* private function thet unset currentfile
|
||||
*/
|
||||
function UnSetCurrentFile(pCurrentFile){
|
||||
var lRet_b = DOM.isCurrentFile(pCurrentFile);
|
||||
|
||||
if(!pCurrentFile)
|
||||
DOM.addCloudStatus({
|
||||
code : -1,
|
||||
|
|
@ -23,8 +25,6 @@ var CloudCommander, $, Util, DOM, CloudFunc;
|
|||
'could not be none'
|
||||
});
|
||||
|
||||
var lRet_b = DOM.isCurrentFile(pCurrentFile);
|
||||
|
||||
if(lRet_b)
|
||||
DOM.removeClass(pCurrentFile, getCurrentFile());
|
||||
|
||||
|
|
@ -129,9 +129,10 @@ var CloudCommander, $, Util, DOM, CloudFunc;
|
|||
XMLHTTP.open(lType, pParams.url, true);
|
||||
XMLHTTP.send(lData);
|
||||
|
||||
if( !Util.isFunction(lSuccess_f) )
|
||||
console.log('error in DOM.ajax onSuccess:', pParams) &&
|
||||
if( !Util.isFunction(lSuccess_f) ){
|
||||
console.log('error in DOM.ajax onSuccess:', pParams);
|
||||
console.log(pParams);
|
||||
}
|
||||
|
||||
XMLHTTP.onreadystatechange = function(pEvent){
|
||||
if (XMLHTTP.readyState === 4 /* Complete */){
|
||||
|
|
|
|||
|
|
@ -112,8 +112,8 @@ var Util, DOM, $;
|
|||
parentBorderLeftWidth +
|
||||
pElement.clientWidth / 2;
|
||||
|
||||
if ( (overTop || overBottom || overLeft || overRight)
|
||||
&& !centerIfNeeded)
|
||||
if ( (overTop || overBottom || overLeft || overRight) &&
|
||||
!centerIfNeeded)
|
||||
pElement.scrollIntoView(alignWithTop);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -236,11 +236,11 @@ var CloudCommander, Util, DOM;
|
|||
var lC = lCurrentFile,
|
||||
tryCatch = function(pCurrentFile){
|
||||
Util.tryCatch(function(){
|
||||
pCurrentFile
|
||||
.previousSibling
|
||||
return pCurrentFile
|
||||
.previousSibling
|
||||
.previousSibling
|
||||
.previousSibling;
|
||||
.previousSibling
|
||||
.previousSibling;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -82,14 +82,14 @@ var CloudCommander, DOM, Util, io;
|
|||
}
|
||||
Messages = [];
|
||||
}
|
||||
|
||||
|
||||
lStdout = pMsg.stdout;
|
||||
lStderr = pMsg.stderr;
|
||||
|
||||
if(lStdout)
|
||||
lResult = lTerm.echo(lStdout);
|
||||
|
||||
if(lStderr && lStderr.code != 1)
|
||||
if(lStderr && lStderr.code !== 1)
|
||||
lResult = lTerm.error(lStderr.toString());
|
||||
}
|
||||
else{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ var CloudCommander, Util, DOM, $, Github, cb;
|
|||
|
||||
cloudcmd.Storage = {};
|
||||
|
||||
cb = function (err, data){ console.log(err || data);}
|
||||
cb = function (err, data){ console.log(err || data);};
|
||||
|
||||
/* PRIVATE FUNCTIONS */
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ var CloudCommander, Util, DOM, CloudFunc, $;
|
|||
},
|
||||
padding : 0
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* function loads css and js of FancyBox
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ var CloudFunc, exports;
|
|||
lFS_s +
|
||||
lNoJS_s +
|
||||
lTitle +
|
||||
'"/"' +
|
||||
'/' +
|
||||
_l +
|
||||
'/' +
|
||||
lHrefEnd;
|
||||
|
|
@ -430,7 +430,7 @@ var CloudFunc, exports;
|
|||
'' : ' target="_blank"') +
|
||||
|
||||
' title="' + files[i].name +'"' +
|
||||
'draggable=true>' + files[i].name +
|
||||
' draggable=true>' + files[i].name +
|
||||
"</a>" +
|
||||
'</span>';
|
||||
/* если папка - не выводим размер */
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ var Util, exports;
|
|||
*/
|
||||
Util.strCmp = function (pStr1, pStr2){
|
||||
return this.isContainStr(pStr1, pStr2) &&
|
||||
pStr1.length == pStr2.length;
|
||||
pStr1.length === pStr2.length;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
89
test/test.js
89
test/test.js
|
|
@ -1,8 +1,12 @@
|
|||
var CloudFunc = require('../lib/cloudfunc');
|
||||
var assert = require('assert');
|
||||
|
||||
try{
|
||||
var lJSON = [{
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
var DIR = process.cwd() + '/',
|
||||
main = require(DIR + 'lib/server/main'),
|
||||
|
||||
CloudFunc = main.cloudfunc,
|
||||
|
||||
lJSON = [{
|
||||
"path": "/etc/X11/",
|
||||
"size": "dir"
|
||||
}, {
|
||||
|
|
@ -17,8 +21,10 @@ try{
|
|||
"mode": "100755"
|
||||
}];
|
||||
|
||||
console.time('CloudFunc.buildFromJSON');
|
||||
start();
|
||||
var lResult = CloudFunc.buildFromJSON(lJSON);
|
||||
end();
|
||||
|
||||
var lExpect =
|
||||
'<li class=path>' +
|
||||
'<span class="path-icon clear-cache"' +
|
||||
|
|
@ -27,7 +33,7 @@ try{
|
|||
'<span class="path-icon refresh-icon" title="refresh (Ctrl+R)">'+
|
||||
'<a href="/fs/no-js/etc/X11"></a></span>' +
|
||||
'<span>' +
|
||||
'<a class=links href="/fs/no-js" title=""/"">/</a>' +
|
||||
'<a class=links href="/fs/no-js" title="/">/</a>' +
|
||||
'<a class=links href="/fs/no-js/etc" title="/etc">' +
|
||||
'etc' +
|
||||
'</a>/X11/' +
|
||||
|
|
@ -40,38 +46,53 @@ try{
|
|||
'<span class=owner>owner</span>' +
|
||||
'<span class=mode>mode</span>' +
|
||||
'</li>' +
|
||||
'<li class=current-file>' +
|
||||
'<span class="mini-icon directory"></span>' +
|
||||
'<span class=name><a href="/fs/no-js/etc">..</a></span>' +
|
||||
'<span class=size><dir></span>' +
|
||||
'<span class=owner>.</span><span class=mode></span>' +
|
||||
'</li>' +
|
||||
'<li class>' +
|
||||
'<li draggable class=current-file>' +
|
||||
'<span class="mini-icon directory"></span>' +
|
||||
'<span class=name>' +
|
||||
'<a href="/fs/no-js/etc/X11/applnk">applnk</a>' +
|
||||
'<a href="/fs/no-js/etc" draggable=true>..</a>' +
|
||||
'</span>' +
|
||||
'<span class=size><dir></span>' +
|
||||
'<span class=owner>root</span>' +
|
||||
'<span class=mode>rwx r-x r-x</span>' +
|
||||
'<span class=owner>.</span>' +
|
||||
'<span class=mode></span>' +
|
||||
'</li>' +
|
||||
'<li class>' +
|
||||
'<span class="mini-icon text-file"></span>' +
|
||||
'<span class=name>' +
|
||||
'<a href="/fs/no-js/etc/X11/prefdm" target="_blank">' +
|
||||
'prefdm' +
|
||||
'<li draggable class>' +
|
||||
'<span draggable class="mini-icon directory"></span>' +
|
||||
'<span draggable class=name>' +
|
||||
'<a href="/fs/no-js/etc/X11/applnk" ' +
|
||||
'title="applnk" draggable=true>applnk</a>' +
|
||||
'</span>' +
|
||||
'<span draggable class=size><dir></span>' +
|
||||
'<span draggable class=owner>root</span>' +
|
||||
'<span draggable class=mode>rwx r-x r-x</span>' +
|
||||
'</li>' +
|
||||
'<li draggable class>' +
|
||||
'<span draggable class="mini-icon text-file"></span>' +
|
||||
'<span draggable class=name>' +
|
||||
'<a href="/fs/no-js/etc/X11/prefdm" ' +
|
||||
'target="_blank" title="prefdm" draggable=true>' +
|
||||
'prefdm' +
|
||||
'</a>' +
|
||||
'</span>' +
|
||||
'<span class=size>1.30kb</span>' +
|
||||
'<span class=owner>root</span>' +
|
||||
'<span class=mode>rwx r-x r-x</span>' +
|
||||
'</li>1';
|
||||
'<span draggable class=size>1.30kb</span>' +
|
||||
'<span draggable class=owner>root</span>' +
|
||||
'<span draggable class=mode>rwx r-x r-x</span>' +
|
||||
'</li>';
|
||||
|
||||
for(var i = 0, n = lExpect.length; i < n; i++)
|
||||
if(lResult[i] !== lExpect[i]){
|
||||
console.log('Error in char number: ' + i + '\n' +
|
||||
'Expect: ' + lExpect.substr(i) + '\n' +
|
||||
'Result: ' + lResult.substr(i) );
|
||||
break;
|
||||
}
|
||||
if(i===n)
|
||||
console.log('CloudFunc.buildFromJSON: OK');
|
||||
|
||||
console.timeEnd('CloudFunc.buildFromJSON');
|
||||
assert.equal(
|
||||
lResult,
|
||||
lExpect, 'Something wrong in buildFromJSON');
|
||||
}
|
||||
catch(pError){
|
||||
console.log(pError);
|
||||
}
|
||||
|
||||
function start(){
|
||||
return console.time('CloudFunc.buildFromJSON');
|
||||
}
|
||||
function end(){
|
||||
return console.timeEnd('CloudFunc.buildFromJSON');
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
29
test/test.sh
29
test/test.sh
|
|
@ -1,15 +1,16 @@
|
|||
set jshint = "../node_modules/jshint/bin/hint --config ./test/.jshintrc"
|
||||
echo "jshint server.js client.js cloudcmd.js"
|
||||
jshint server.js client.js cloudcmd.js
|
||||
echo "jshint lib/cloudfunc.js lib/client/keyBinding.js"
|
||||
jshint ./lib/util.js ./lib/cloudfunc.js ./node_modules/minify/minify.js ./lib/client/keyBinding.js
|
||||
jshint ./lib/client/dom.js ./lib/client/ie.js ./lib/client/menu.js ./lib/client/socket.js ./lib/client/terminal.js ./lib/client/viewer.js ./lib/client/storage/_github.js ./lib/client/menu.js ./lib/client/editor/_codemirror.js
|
||||
echo "jshint ./package.json ./config.json"
|
||||
jshint ./package.json ./config.json
|
||||
#linting css files
|
||||
npm i recess
|
||||
echo "recess css/*.css"
|
||||
./node_modules/recess/bin/recess ../css/*.css
|
||||
node ./test/test.js
|
||||
node cloudcmd.js test
|
||||
#!/bin/sh
|
||||
echo "jshint server.js client.js cloudcmd.js"
|
||||
node_modules/jshint/bin/hint --config test/.jshintrc server.js client.js cloudcmd.js
|
||||
echo "jshint lib/cloudfunc.js lib/client/keyBinding.js"
|
||||
node_modules/jshint/bin/hint --config test/.jshintrc lib/util.js lib/cloudfunc.js node_modules/minify/minify.js lib/client/keyBinding.js
|
||||
echo "lib/client/dom.js lib/client/ie.js lib/client/menu.js lib/client/socket.js ./lib/client/terminal.js lib/client/viewer.js lib/client/storage/_github.js lib/client/menu.js lib/client/editor/_codemirror.js"
|
||||
node_modules/jshint/bin/hint --config test/.jshintrc lib/client/dom.js lib/client/ie.js lib/client/menu.js lib/client/socket.js ./lib/client/terminal.js lib/client/viewer.js lib/client/storage/_github.js lib/client/menu.js lib/client/editor/_codemirror.js
|
||||
echo "jshint ./package.json ./config.json"
|
||||
jshint ./package.json ./config.json
|
||||
#linting css files
|
||||
npm i recess
|
||||
echo "recess css/*.css"
|
||||
./node_modules/recess/bin/recess css/*.css
|
||||
node test/test.js
|
||||
node cloudcmd.js test
|
||||
ls ./min
|
||||
Loading…
Add table
Add a link
Reference in a new issue