mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature: client: key: vim: get rid of mock-require
This commit is contained in:
parent
f437a52ff0
commit
c5d9bd7c1f
2 changed files with 15 additions and 13 deletions
|
|
@ -39,9 +39,13 @@ const getOperations = (event, deps) => {
|
|||
|
||||
toggleSelectedFile,
|
||||
Buffer = {},
|
||||
createFindNext = _createFindNext,
|
||||
} = deps;
|
||||
|
||||
return {
|
||||
findNext: createFindNext({
|
||||
setCurrentByName,
|
||||
}),
|
||||
escape: unselectFiles,
|
||||
|
||||
remove: () => {
|
||||
|
|
@ -119,11 +123,6 @@ const getOperations = (event, deps) => {
|
|||
setCurrentByName(result);
|
||||
},
|
||||
|
||||
findNext: () => {
|
||||
const name = finder.findNext();
|
||||
setCurrentByName(name);
|
||||
},
|
||||
|
||||
findPrevious: () => {
|
||||
const name = finder.findPrevious();
|
||||
setCurrentByName(name);
|
||||
|
|
@ -132,3 +131,10 @@ const getOperations = (event, deps) => {
|
|||
};
|
||||
|
||||
module.exports.selectFile = selectFileNotParent;
|
||||
|
||||
const _createFindNext = (overrides = {}) => () => {
|
||||
const {setCurrentByName} = overrides;
|
||||
const name = finder.findNext();
|
||||
|
||||
setCurrentByName(name);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -570,17 +570,13 @@ test('cloudcmd: client: find', (t) => {
|
|||
|
||||
test('cloudcmd: client: key: n', (t) => {
|
||||
const findNext = stub();
|
||||
const createFindNext = stub().returns(findNext);
|
||||
|
||||
mockRequire(pathFind, {
|
||||
findNext,
|
||||
});
|
||||
|
||||
const vim = reRequire(pathVim);
|
||||
const event = {};
|
||||
|
||||
vim('n', event);
|
||||
|
||||
stopAll();
|
||||
vim('n', event, {
|
||||
createFindNext,
|
||||
});
|
||||
|
||||
t.calledWithNoArgs(findNext, 'should call findNext');
|
||||
t.end();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue