diff --git a/client/modules/user-menu/index.js b/client/modules/user-menu/index.js index 94eaac8a..249e4e9c 100644 --- a/client/modules/user-menu/index.js +++ b/client/modules/user-menu/index.js @@ -36,6 +36,7 @@ module.exports.hide = hide; const getKey = (a) => a.split(' - ')[0]; const beginWith = (a) => (b) => a === getKey(b); +const notPrivate = ([a]) => a !== '_'; const {CurrentInfo} = DOM; @@ -49,7 +50,9 @@ async function show() { if (error) return Dialog.alert(`User menu error: ${error.message}`); - const options = Object.keys(userMenu); + const options = Object + .keys(userMenu) + .filter(notPrivate); const button = createElement('button', { className: 'cloudcmd-user-menu-button', diff --git a/static/user-menu.js b/static/user-menu.js index 32aedb5e..42acb5da 100644 --- a/static/user-menu.js +++ b/static/user-menu.js @@ -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 = []; diff --git a/static/user-menu.spec.js b/static/user-menu.spec.js index 827ac76e..b493cc81 100644 --- a/static/user-menu.spec.js +++ b/static/user-menu.spec.js @@ -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(),