diff --git a/server/root.js b/server/root.js index 32c2b9dd..0d405d3c 100644 --- a/server/root.js +++ b/server/root.js @@ -2,6 +2,6 @@ const mellow = require('mellow'); -module.exports = (dir, root) => { - return mellow.webToWin(dir, root || '/'); +module.exports = (dir, root, {webToWin = mellow.webToWin} = {}) => { + return webToWin(dir, root || '/'); }; diff --git a/server/root.spec.js b/server/root.spec.js index 9af58e18..56c08a36 100644 --- a/server/root.spec.js +++ b/server/root.spec.js @@ -3,34 +3,18 @@ const {test, stub} = require('supertape'); const mockRequire = require('mock-require'); -const {reRequire, stopAll} = mockRequire; - -const pathConfig = './config'; -const pathRoot = './root'; +const root = require('./root'); test('cloudcmd: root: mellow', (t) => { - const config = stub().returns(''); const webToWin = stub(); - - const mellow = { - webToWin, - }; - - mockRequire('mellow', mellow); - mockRequire(pathConfig, config); - - const root = reRequire(pathRoot); + const dir = 'hello'; const dirRoot = '/'; - - root(dir); - - mockRequire.stop('mellow'); - mockRequire.stopAll(pathConfig); - reRequire(pathRoot); - - stopAll(); - + + root(dir, '', { + webToWin, + }); + t.calledWith(webToWin, [dir, dirRoot], 'should call mellow'); t.end(); });