mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-22 18:29:26 +00:00
chore: lint
This commit is contained in:
parent
c7f9090126
commit
0655988ed7
2 changed files with 29 additions and 30 deletions
|
|
@ -2,19 +2,18 @@
|
|||
|
||||
const {test, stub} = require('supertape');
|
||||
|
||||
const mockRequire = require('mock-require');
|
||||
const root = require('./root');
|
||||
|
||||
test('cloudcmd: root: mellow', (t) => {
|
||||
const webToWin = stub();
|
||||
|
||||
|
||||
const dir = 'hello';
|
||||
const dirRoot = '/';
|
||||
|
||||
|
||||
root(dir, '', {
|
||||
webToWin,
|
||||
});
|
||||
|
||||
|
||||
t.calledWith(webToWin, [dir, dirRoot], 'should call mellow');
|
||||
t.end();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -60,40 +60,40 @@ let Expect = '<div data-name="js-path" class="reduce-text" title="/etc/X11/">' +
|
|||
|
||||
test('cloudfunc: render', (t) => {
|
||||
const template = readFilesSync(FS_DIR, TMPL, 'utf8');
|
||||
|
||||
|
||||
time('CloudFunc.buildFromJSON');
|
||||
const result = CloudFunc.buildFromJSON({
|
||||
prefix: '',
|
||||
data,
|
||||
template,
|
||||
});
|
||||
|
||||
|
||||
Expect += fs.readFileSync(EXPECT_PATH, 'utf8');
|
||||
|
||||
|
||||
let i;
|
||||
const isNotOk = Expect
|
||||
.split('')
|
||||
.some((item, number) => {
|
||||
const ret = result[number] !== item;
|
||||
|
||||
|
||||
if (ret)
|
||||
i = number;
|
||||
|
||||
|
||||
return ret;
|
||||
});
|
||||
|
||||
|
||||
timeEnd('CloudFunc.buildFromJSON');
|
||||
|
||||
|
||||
if (isNotOk) {
|
||||
console.log(`Error in char number: ${i}\n`, `Expect: ${Expect.substr(i)}\n`, `Result: ${result.substr(i)}`);
|
||||
|
||||
|
||||
console.log('buildFromJSON: Not OK');
|
||||
}
|
||||
|
||||
|
||||
t.equal(result, Expect, 'should be equal rendered json data');
|
||||
|
||||
|
||||
htmlLooksLike(result, Expect);
|
||||
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -101,9 +101,9 @@ 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();
|
||||
});
|
||||
|
|
@ -112,9 +112,9 @@ test('cloudfunc: formatMsg: no name', (t) => {
|
|||
const msg = 'hello';
|
||||
const name = null;
|
||||
const status = 'ok';
|
||||
|
||||
|
||||
const result = CloudFunc.formatMsg(msg, name, status);
|
||||
|
||||
|
||||
t.equal(result, 'hello: ok');
|
||||
t.end();
|
||||
});
|
||||
|
|
@ -123,18 +123,18 @@ test('cloudfunc: getTitle', (t) => {
|
|||
const result = CloudFunc.getTitle({
|
||||
path: '/',
|
||||
});
|
||||
|
||||
|
||||
t.equal(result, 'Cloud Commander - /');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudfunc: getTitle: no name', (t) => {
|
||||
const path = '/hello/world';
|
||||
|
||||
|
||||
const result = CloudFunc.getTitle({
|
||||
path,
|
||||
});
|
||||
|
||||
|
||||
t.equal(result, 'Cloud Commander - /hello/world');
|
||||
t.end();
|
||||
});
|
||||
|
|
@ -142,12 +142,12 @@ test('cloudfunc: getTitle: no name', (t) => {
|
|||
test('cloudfunc: getTitle: name, path', (t) => {
|
||||
const name = 'hello';
|
||||
const path = '/hello/world';
|
||||
|
||||
|
||||
const result = CloudFunc.getTitle({
|
||||
name,
|
||||
path,
|
||||
});
|
||||
|
||||
|
||||
t.equal(result, 'hello - /hello/world');
|
||||
t.end();
|
||||
});
|
||||
|
|
@ -156,17 +156,17 @@ test('cloudfunc: getHeaderField', (t) => {
|
|||
const sort = 'name';
|
||||
const order = 'desc';
|
||||
const name = 'name';
|
||||
|
||||
|
||||
const result = CloudFunc.getHeaderField(sort, order, name);
|
||||
const expected = 'name↓';
|
||||
|
||||
|
||||
t.equal(result, expected, 'should set desc arrow');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudfunc: getPathLink: no url', (t) => {
|
||||
const [error] = tryCatch(CloudFunc.getPathLink);
|
||||
|
||||
|
||||
t.ok(error, 'should throw when no url');
|
||||
t.end();
|
||||
});
|
||||
|
|
@ -175,21 +175,21 @@ test('cloudfunc: getPathLink: no template', (t) => {
|
|||
const url = 'http://abc.com';
|
||||
const prefix = '';
|
||||
const [error] = tryCatch(CloudFunc.getPathLink, url, prefix);
|
||||
|
||||
|
||||
t.ok(error, 'should throw when no template');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudfunc: getDotDot', (t) => {
|
||||
const dotDot = CloudFunc.getDotDot('/home');
|
||||
|
||||
|
||||
t.equal(dotDot, '/', 'should return root');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudfunc: getDotDot: two levels deep', (t) => {
|
||||
const dotDot = CloudFunc.getDotDot('/home/coderaiser/');
|
||||
|
||||
|
||||
t.equal(dotDot, '/home', 'should return up level');
|
||||
t.end();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue