mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
chore(cloudcmd) lint
This commit is contained in:
parent
bd5a8afdd5
commit
efb686c332
12 changed files with 43 additions and 29 deletions
|
|
@ -4,7 +4,7 @@ const test = require('supertape');
|
|||
const stub = require('@cloudcmd/stub');
|
||||
const mockRequire = require('mock-require');
|
||||
|
||||
const {reRequire} = mockRequire;
|
||||
const {reRequire, stopAll} = mockRequire;
|
||||
|
||||
test('client: dom: io', (t) => {
|
||||
const sendRequest = stub();
|
||||
|
|
@ -22,6 +22,8 @@ test('client: dom: io', (t) => {
|
|||
url: '/fs/hello?dir',
|
||||
};
|
||||
|
||||
stopAll();
|
||||
|
||||
t.calledWith(sendRequest, [expected]);
|
||||
t.end();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ const test = require('supertape');
|
|||
const stub = require('@cloudcmd/stub');
|
||||
const mockRequire = require('mock-require');
|
||||
|
||||
const {reRequire} = mockRequire;
|
||||
const {reRequire, stopAll} = mockRequire;
|
||||
|
||||
test('cloudcmd: client: dom: renameCurrent: isCurrentFile', async (t) => {
|
||||
const current = {};
|
||||
|
|
@ -18,6 +18,8 @@ test('cloudcmd: client: dom: renameCurrent: isCurrentFile', async (t) => {
|
|||
const renameCurrent = reRequire('./rename-current');
|
||||
await renameCurrent(current);
|
||||
|
||||
stopAll();
|
||||
|
||||
t.calledWith(isCurrentFile, [current], 'should call isCurrentFile');
|
||||
t.end();
|
||||
});
|
||||
|
|
@ -55,6 +57,8 @@ test('cloudcmd: client: dom: renameCurrent: file exist', async (t) => {
|
|||
const expected = 'Directory "hello" already exists. Proceed?';
|
||||
global.CloudCmd = CloudCmd;
|
||||
|
||||
stopAll();
|
||||
|
||||
t.calledWith(confirm, [expected], 'should call confirm');
|
||||
t.end();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ test('cloudcmd: client: key: set next file current', (t) => {
|
|||
vim('j', {});
|
||||
|
||||
t.calledWith(setCurrentFile, [nextSibling], 'should set next file');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -73,7 +72,6 @@ test('cloudcmd: client: key: set next file current', (t) => {
|
|||
vim('j', {});
|
||||
|
||||
t.calledWith(setCurrentFile, [nextSibling], 'should set next file');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -92,7 +90,6 @@ test('cloudcmd: client: key: set next file current: g', (t) => {
|
|||
vim('j', {});
|
||||
|
||||
t.calledWith(setCurrentFile, [nextSibling], 'should ignore g');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -116,7 +113,6 @@ test('cloudcmd: client: key: set +2 file current', (t) => {
|
|||
vim('j', event);
|
||||
|
||||
t.calledWith(setCurrentFile, [last], 'should set next file');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -172,7 +168,6 @@ test('cloudcmd: client: key: delete +2 files from current', (t) => {
|
|||
vim('j', event);
|
||||
|
||||
t.calledWith(show, ['delete'], 'should call delete');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -201,7 +196,6 @@ test('cloudcmd: client: key: copy: no', (t) => {
|
|||
vim('y', {});
|
||||
|
||||
t.notOk(copy.called, 'should not copy files');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -237,7 +231,6 @@ test('cloudcmd: client: key: paste', (t) => {
|
|||
vim('p', {});
|
||||
|
||||
t.ok(paste.calledWith(), 'should paste files');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -286,7 +279,6 @@ test('cloudcmd: client: key: set last file current: shift + g', (t) => {
|
|||
vim('G', {});
|
||||
|
||||
t.calledWith(setCurrentFile, [last], 'should set last file');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -307,7 +299,6 @@ test('cloudcmd: client: key: set last file current: $', (t) => {
|
|||
vim('$', {});
|
||||
|
||||
t.calledWith(setCurrentFile, [last], 'should set last file');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -330,7 +321,6 @@ test('cloudcmd: client: key: set first file current: gg', (t) => {
|
|||
vim('g', {});
|
||||
|
||||
t.calledWith(setCurrentFile, [first], 'should set first file');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -352,7 +342,6 @@ test('cloudcmd: client: key: set first file current: ^', (t) => {
|
|||
vim('^', {});
|
||||
|
||||
t.calledWith(setCurrentFile, [first], 'should set first file');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -367,7 +356,6 @@ test('cloudcmd: client: key: visual', (t) => {
|
|||
vim('v', {});
|
||||
|
||||
t.calledWith(toggleSelectedFile, [element], 'should toggle selection');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -431,7 +419,7 @@ test('cloudcmd: client: key: n', (t) => {
|
|||
|
||||
vim('n', event);
|
||||
|
||||
stopAll(pathFind);
|
||||
stopAll();
|
||||
|
||||
t.ok(findNext.calledWith(), 'should call findNext');
|
||||
t.end();
|
||||
|
|
@ -449,7 +437,7 @@ test('cloudcmd: client: key: N', (t) => {
|
|||
|
||||
vim('N', event);
|
||||
|
||||
stopAll(pathFind);
|
||||
stopAll();
|
||||
|
||||
t.ok(findPrevious.calledWith(), 'should call findPrevious');
|
||||
t.end();
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ module.exports = function loadModule(params) {
|
|||
|
||||
CloudCmd[name] = () => {
|
||||
exec(doBefore);
|
||||
|
||||
const {prefix} = CloudCmd;
|
||||
const pathFull = prefix + CloudCmd.DIRCLIENT_MODULES + path + '.js';
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ const test = require('supertape');
|
|||
const mockRequire = require('mock-require');
|
||||
const stub = require('@cloudcmd/stub');
|
||||
|
||||
const {stopAll} = mockRequire;
|
||||
|
||||
test('cloudcmd: client: polyfill: scrollIntoViewIfNeaded', (t) => {
|
||||
const {DOM} = global;
|
||||
const scroll = stub();
|
||||
|
|
@ -26,6 +28,8 @@ test('cloudcmd: client: polyfill: scrollIntoViewIfNeaded', (t) => {
|
|||
block: 'nearest',
|
||||
}];
|
||||
|
||||
stopAll();
|
||||
|
||||
t.calledWith(scroll, args, 'should call scrollIntoViewIfNeaded');
|
||||
t.end();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const autoGlobals = require('auto-globals');
|
|||
const test = autoGlobals(require('supertape'));
|
||||
const stub = require('@cloudcmd/stub');
|
||||
const mockRequire = require('mock-require');
|
||||
const {reRequire} = mockRequire;
|
||||
const {reRequire, stopAll} = mockRequire;
|
||||
|
||||
test('cloudcmd: client: view: initConfig', (t) => {
|
||||
let config;
|
||||
|
|
@ -78,6 +78,8 @@ test('cloudcmd: client: view: html', (t) => {
|
|||
const [first] = open.args;
|
||||
const [arg] = first;
|
||||
|
||||
stopAll();
|
||||
|
||||
t.deepEqual(first, [arg, _Config]);
|
||||
t.end();
|
||||
});
|
||||
|
|
@ -101,6 +103,8 @@ test('cloudcmd: client: view: createIframe', (t) => {
|
|||
width: '100%',
|
||||
};
|
||||
|
||||
stopAll();
|
||||
|
||||
t.calledWith(createElement, ['iframe', expected]);
|
||||
t.end();
|
||||
});
|
||||
|
|
@ -118,6 +122,8 @@ test('cloudcmd: client: view: createIframe: returns', (t) => {
|
|||
const src = '/hello.html';
|
||||
const result = _createIframe(src);
|
||||
|
||||
stopAll();
|
||||
|
||||
t.equal(result, el);
|
||||
t.end();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ test('cloudcmd: auth: reject', (t) => {
|
|||
|
||||
const username = 'root';
|
||||
const password = 'toor';
|
||||
|
||||
config('auth', true);
|
||||
config('username', username);
|
||||
config('password', password);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
const test = require('supertape');
|
||||
const stub = require('@cloudcmd/stub');
|
||||
const mockRequire = require('mock-require');
|
||||
const {reRequire} = mockRequire;
|
||||
const {reRequire, stopAll} = mockRequire;
|
||||
|
||||
const pathConfig = './config';
|
||||
const pathRoot = './root';
|
||||
|
|
@ -29,6 +29,8 @@ test('cloudcmd: root: mellow', (t) => {
|
|||
mockRequire.stopAll(pathConfig);
|
||||
reRequire(pathRoot);
|
||||
|
||||
stopAll();
|
||||
|
||||
t.calledWith(webToWin, [dir, dirRoot], 'should call mellow');
|
||||
t.end();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ const terminalPath = './terminal';
|
|||
const terminal = require('./terminal');
|
||||
const {createConfigManager} = require('./cloudcmd');
|
||||
|
||||
const {stopAll} = mockRequire;
|
||||
|
||||
test('cloudcmd: terminal: disabled', (t) => {
|
||||
const config = createConfigManager();
|
||||
config('terminal', false);
|
||||
|
|
@ -38,6 +40,8 @@ test('cloudcmd: terminal: enabled', (t) => {
|
|||
const terminal = require(terminalPath);
|
||||
terminal(arg);
|
||||
|
||||
stopAll();
|
||||
|
||||
t.calledWith(term, [arg], 'should call terminal');
|
||||
t.end();
|
||||
});
|
||||
|
|
@ -67,12 +71,13 @@ test('cloudcmd: terminal: no arg', (t) => {
|
|||
|
||||
mockRequire('gritty', gritty);
|
||||
const config = createConfigManager();
|
||||
|
||||
config('terminal', true);
|
||||
config('terminalPath', 'gritty');
|
||||
|
||||
const result = terminal(config);
|
||||
|
||||
mockRequire.stop('gritty');
|
||||
stopAll();
|
||||
|
||||
t.equal(result, gritty);
|
||||
t.end();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const test = require('supertape');
|
|||
const stub = require('@cloudcmd/stub');
|
||||
const tryCatch = require('try-catch');
|
||||
const mockRequire = require('mock-require');
|
||||
const {reRequire} = mockRequire;
|
||||
const {reRequire, stopAll} = mockRequire;
|
||||
|
||||
const dir = '..';
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ test('validate: root: stat', (t) => {
|
|||
const msg = 'cloudcmd --root: %s';
|
||||
fs.statSync = statSync;
|
||||
|
||||
mockRequire.stop(exitPath);
|
||||
stopAll();
|
||||
|
||||
t.calledWith(fn, [msg, error], 'should call fn');
|
||||
t.end();
|
||||
|
|
@ -80,7 +80,7 @@ test('validate: packer: not valid', (t) => {
|
|||
|
||||
packer('hello');
|
||||
|
||||
mockRequire.stop(exitPath);
|
||||
stopAll();
|
||||
|
||||
t.calledWith(fn, [msg], 'should call fn');
|
||||
t.end();
|
||||
|
|
@ -96,7 +96,7 @@ test('validate: editor: not valid', (t) => {
|
|||
|
||||
editor('hello');
|
||||
|
||||
mockRequire.stop(exitPath);
|
||||
stopAll();
|
||||
|
||||
t.calledWith(fn, [msg], 'should call fn');
|
||||
t.end();
|
||||
|
|
@ -110,7 +110,7 @@ test('validate: columns', (t) => {
|
|||
|
||||
columns('name-size-date');
|
||||
|
||||
mockRequire.stop(exitPath);
|
||||
stopAll();
|
||||
|
||||
t.notOk(fn.called, 'should not call exit');
|
||||
t.end();
|
||||
|
|
@ -130,8 +130,7 @@ test('validate: columns: wrong', (t) => {
|
|||
|
||||
columns('hello');
|
||||
|
||||
mockRequire.stop(exitPath);
|
||||
mockRequire.stop(columnsPath);
|
||||
stopAll();
|
||||
|
||||
t.calledWith(fn, [msg], 'should call exit');
|
||||
t.end();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const {Volume} = require('memfs');
|
|||
const {ufs} = require('unionfs');
|
||||
|
||||
const mockRequire = require('mock-require');
|
||||
const {reRequire} = mockRequire;
|
||||
const {reRequire, stopAll} = mockRequire;
|
||||
const serveOnce = require('serve-once');
|
||||
|
||||
const cloudcmdPath = '../../';
|
||||
|
|
@ -60,7 +60,7 @@ test('cloudcmd: rest: move', async (t) => {
|
|||
body: files,
|
||||
});
|
||||
|
||||
mockRequire.stop('fs');
|
||||
stopAll();
|
||||
|
||||
t.equal(body, 'move: ok("["move.txt"]")', 'should move');
|
||||
t.end();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const {Volume} = require('memfs');
|
|||
const {ufs} = require('unionfs');
|
||||
|
||||
const mockRequire = require('mock-require');
|
||||
const {reRequire} = mockRequire;
|
||||
const {reRequire, stopAll} = mockRequire;
|
||||
const serveOnce = require('serve-once');
|
||||
|
||||
const cloudcmdPath = '../../';
|
||||
|
|
@ -56,6 +56,8 @@ test('cloudcmd: rest: rename', async (t) => {
|
|||
|
||||
const expected = 'rename: ok("{"from":"/fixture/mv.txt","to":"/fixture/tmp/mv.txt"}")';
|
||||
|
||||
stopAll();
|
||||
|
||||
t.equal(body, expected, 'should move');
|
||||
t.end();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue