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,
|
toggleSelectedFile,
|
||||||
Buffer = {},
|
Buffer = {},
|
||||||
|
createFindNext = _createFindNext,
|
||||||
} = deps;
|
} = deps;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
findNext: createFindNext({
|
||||||
|
setCurrentByName,
|
||||||
|
}),
|
||||||
escape: unselectFiles,
|
escape: unselectFiles,
|
||||||
|
|
||||||
remove: () => {
|
remove: () => {
|
||||||
|
|
@ -119,11 +123,6 @@ const getOperations = (event, deps) => {
|
||||||
setCurrentByName(result);
|
setCurrentByName(result);
|
||||||
},
|
},
|
||||||
|
|
||||||
findNext: () => {
|
|
||||||
const name = finder.findNext();
|
|
||||||
setCurrentByName(name);
|
|
||||||
},
|
|
||||||
|
|
||||||
findPrevious: () => {
|
findPrevious: () => {
|
||||||
const name = finder.findPrevious();
|
const name = finder.findPrevious();
|
||||||
setCurrentByName(name);
|
setCurrentByName(name);
|
||||||
|
|
@ -132,3 +131,10 @@ const getOperations = (event, deps) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.selectFile = selectFileNotParent;
|
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) => {
|
test('cloudcmd: client: key: n', (t) => {
|
||||||
const findNext = stub();
|
const findNext = stub();
|
||||||
|
const createFindNext = stub().returns(findNext);
|
||||||
|
|
||||||
mockRequire(pathFind, {
|
|
||||||
findNext,
|
|
||||||
});
|
|
||||||
|
|
||||||
const vim = reRequire(pathVim);
|
|
||||||
const event = {};
|
const event = {};
|
||||||
|
|
||||||
vim('n', event);
|
vim('n', event, {
|
||||||
|
createFindNext,
|
||||||
stopAll();
|
});
|
||||||
|
|
||||||
t.calledWithNoArgs(findNext, 'should call findNext');
|
t.calledWithNoArgs(findNext, 'should call findNext');
|
||||||
t.end();
|
t.end();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue