mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(user-menu) add ability to ignore private methods
This commit is contained in:
parent
554023c839
commit
8961841847
3 changed files with 56 additions and 1 deletions
|
|
@ -70,6 +70,7 @@ async function readDefaultMenu({prefix}) {
|
|||
return data;
|
||||
}
|
||||
|
||||
module.exports._selectNames = selectNames;
|
||||
function selectNames(names, panel, {selectFile, getCurrentByName}) {
|
||||
for (const name of names) {
|
||||
const file = getCurrentByName(name, panel);
|
||||
|
|
@ -77,6 +78,7 @@ function selectNames(names, panel, {selectFile, getCurrentByName}) {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports._compare = compare;
|
||||
function compare(a, b) {
|
||||
const result = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -124,6 +124,56 @@ test('cloudcmd: static: user menu: compare directories', async (t) => {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: static: user menu: compare directories: select names', async (t) => {
|
||||
const {_selectNames} = defaultMenu;
|
||||
const selectFile = stub();
|
||||
const file = {};
|
||||
const getCurrentByName = stub().returns(file);
|
||||
|
||||
const names = ['hi'];
|
||||
const panel = {};
|
||||
|
||||
_selectNames(names, panel, {
|
||||
selectFile,
|
||||
getCurrentByName,
|
||||
});
|
||||
|
||||
t.ok(selectFile.calledWith(file), 'should call selectFile');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: static: user menu: compare directories: select names: getCurrentByName', async (t) => {
|
||||
const {_selectNames} = defaultMenu;
|
||||
const selectFile = stub();
|
||||
const getCurrentByName = stub();
|
||||
|
||||
const name = 'hi';
|
||||
const names = [name];
|
||||
const panel = {};
|
||||
|
||||
_selectNames(names, panel, {
|
||||
selectFile,
|
||||
getCurrentByName,
|
||||
});
|
||||
|
||||
t.ok(getCurrentByName.calledWith(name, panel), 'should call selectFile');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: static: user menu: compare directories: select names: compare', async (t) => {
|
||||
const {_compare} = defaultMenu;
|
||||
const a = [1, 2];
|
||||
const b = [1, 3];
|
||||
|
||||
const result = _compare(a, b);
|
||||
const expected = [
|
||||
2,
|
||||
];
|
||||
|
||||
t.deepEqual(result, expected, 'should equal');
|
||||
t.end();
|
||||
});
|
||||
|
||||
function getDOM() {
|
||||
const IO = {
|
||||
write: stub(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue