From a52a6aae628f7dd1b1032d069a2f02a1e3bac63e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 15 Jul 2026 09:36:03 +0000 Subject: [PATCH] test: coverage --- client/key/vim/find.spec.js | 32 +++++++++++++++++++++++++++++++- server/rest/index.js | 16 ++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/client/key/vim/find.spec.js b/client/key/vim/find.spec.js index 59c9a249..c1164aea 100644 --- a/client/key/vim/find.spec.js +++ b/client/key/vim/find.spec.js @@ -1,6 +1,6 @@ import test from 'supertape'; import {getDOM} from './globals.fixture.js'; -import {_next, _previous} from './find.js'; +import {_next, _previous, find, findNext, findPrevious} from './find.js'; globalThis.DOM = getDOM(); @@ -11,9 +11,39 @@ test('cloudcmd: client: vim: _next', (t) => { t.end(); }); +test('cloudcmd: client: vim: _next: increment', (t) => { + const result = _next(0, 2); + + t.equal(result, 1, 'should return 1'); + t.end(); +}); + test('cloudcmd: client: vim: _previous', (t) => { const result = _previous(0, 2); t.equal(result, 1, 'should return 1'); t.end(); }); + +test('cloudcmd: client: vim: _previous: decrement', (t) => { + const result = _previous(1, 2); + + t.equal(result, 0, 'should return 0'); + t.end(); +}); + +test('cloudcmd: client: vim: findNext: after find', (t) => { + find('a', ['alpha', 'beta', 'apple']); + const result = findNext(); + + t.equal(result, 'beta', 'should return next found name'); + t.end(); +}); + +test('cloudcmd: client: vim: findPrevious: after find', (t) => { + find('a', ['alpha', 'beta', 'apple']); + const result = findPrevious(); + + t.equal(result, 'apple', 'should return previous found name'); + t.end(); +}); diff --git a/server/rest/index.js b/server/rest/index.js index 68bec54e..c3a3eda0 100644 --- a/server/rest/index.js +++ b/server/rest/index.js @@ -32,6 +32,8 @@ const UserError = (msg) => { return error; }; +export const _UserError = UserError; + export default currify(({config, fs = _fs, moveFiles = _moveFiles}, request, response, next) => { const name = ponse.getPathName(request); const regExp = RegExp(`^${apiURL}`); @@ -153,6 +155,8 @@ function getPackReg(packer) { return /\.tar\.gz$/; } +export const _getPackReg = getPackReg; + function streamPack(cmd, response, packer) { const noop = () => {}; const filename = cmd.replace(getPackReg(packer), ''); @@ -172,6 +176,8 @@ function getCMD(cmd) { return cmd; } +export const _getCMD = getCMD; + const getMoveMsg = (names) => formatMsg('move', names); const getRenameMsg = (from, to) => { @@ -276,6 +282,8 @@ function rename(rootDir, from, to, fs, callback) { return fs.rename(fromRooted, toRooted, fn); } +export const _rename = rename; + function pack(from, to, names, config, fn) { const rootDir = config('root'); const packer = config('packer'); @@ -294,6 +302,8 @@ function pack(from, to, names, config, fn) { operation('pack', packer, from, to, names, fn); } +export const _pack = pack; + function extract(from, to, config, fn) { const rootDir = config('root'); @@ -307,6 +317,8 @@ function extract(from, to, config, fn) { operation('extract', config('packer'), from, to, fn); } +export const _extract = extract; + function getPacker(operation, packer) { if (operation === 'extract') return inly; @@ -317,6 +329,8 @@ function getPacker(operation, packer) { return jaguar.pack; } +export const _getPacker = getPacker; + function operation(op, packer, from, to, names, fn) { if (!fn) { fn = names; @@ -345,6 +359,8 @@ function operation(op, packer, from, to, names, fn) { }); } +export const _operation = operation; + function copy(from, to, names, fn) { copymitter(from, to, names) .on('error', fn)