diff --git a/client/dom/index.js b/client/dom/index.js index bfb4386c..9bb7b4fe 100644 --- a/client/dom/index.js +++ b/client/dom/index.js @@ -729,17 +729,19 @@ module.exports.getPackerExt = (type) => { return '.tar.gz'; }; -module.exports.goToDirectory = async () => { - const msg = 'Go to directory:'; +module.exports.goToDirectory = async (overrides = {}) => { const {Dialog} = DOM; + const {prompt = Dialog.prompt, changeDir = CloudCmd.changeDir} = overrides; + + const msg = 'Go to directory:'; const {dirPath} = CurrentInfo; - const [cancel, path = dirPath] = await Dialog.prompt(msg, dirPath); + const [cancel, path = dirPath] = await prompt(msg, dirPath); if (cancel) return; - await CloudCmd.changeDir(path); + await changeDir(path); }; module.exports.duplicatePanel = async () => { diff --git a/client/dom/index.spec.js b/client/dom/index.spec.js index c5843d11..18dc7ea1 100644 --- a/client/dom/index.spec.js +++ b/client/dom/index.spec.js @@ -3,30 +3,20 @@ require('css-modules-require-hook/preset'); const {test, stub} = require('supertape'); -const mockRequire = require('mock-require'); -const {getCSSVar} = require('./index'); -const {reRequire, stopAll} = mockRequire; +const {getCSSVar, goToDirectory} = require('./index'); global.CloudCmd = {}; test('cloudcmd: client: dom: goToDirectory', async (t) => { const path = ''; - const {CloudCmd} = global; const changeDir = stub(); const prompt = stub().returns([null, path]); - CloudCmd.changeDir = changeDir; - - mockRequire('./dialog', { + await goToDirectory({ prompt, + changeDir, }); - const {goToDirectory} = reRequire('.'); - - await goToDirectory(); - - stopAll(); - t.calledWith(changeDir, [path]); t.end(); });