chore(cloudcmd) lint

This commit is contained in:
coderaiser 2021-12-04 01:21:02 +02:00
parent bd5a8afdd5
commit efb686c332
12 changed files with 43 additions and 29 deletions

View file

@ -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();
});

View file

@ -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();
});

View file

@ -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();

View file

@ -27,6 +27,7 @@ module.exports = function loadModule(params) {
CloudCmd[name] = () => {
exec(doBefore);
const {prefix} = CloudCmd;
const pathFull = prefix + CloudCmd.DIRCLIENT_MODULES + path + '.js';

View file

@ -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();
});

View file

@ -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();
});