diff --git a/client/dom/current-file.js b/client/dom/current-file.js index ed2aa790..693bec2e 100644 --- a/client/dom/current-file.js +++ b/client/dom/current-file.js @@ -21,6 +21,8 @@ const CURRENT_FILE = 'current-file'; const NBSP_REG = RegExp(String.fromCharCode(160), 'g'); const SPACE = ' '; +module.exports._CURRENT_FILE = CURRENT_FILE; + /** * set name from current (or param) file * diff --git a/client/dom/current-file.spec.js b/client/dom/current-file.spec.js index 0b25c589..6efcf00b 100644 --- a/client/dom/current-file.spec.js +++ b/client/dom/current-file.spec.js @@ -8,6 +8,7 @@ const wraptile = require('wraptile'); const returns = wraptile(id); const currentFile = require('./current-file'); +const {_CURRENT_FILE} = currentFile; test('current-file: setCurrentName: setAttribute', (t) => { const { @@ -136,6 +137,49 @@ test('current-file: getParentDirPath: result', (t) => { t.end(); }); +test('current-file: isCurrentFile: no', (t) => { + const { + DOM, + CloudCmd, + } = global; + + global.DOM = getDOM(); + global.CloudCmd = getCloudCmd(); + + const result = currentFile.isCurrentFile(); + const expect = false; + + global.DOM = DOM; + global.CloudCmd = CloudCmd; + + t.equal(result, expect, 'should equal'); + t.end(); +}); + +test('current-file: isCurrentFile', (t) => { + const { + DOM, + CloudCmd, + } = global; + + const isContainClass = sinon.stub(); + + global.DOM = getDOM({ + isContainClass + }); + + global.CloudCmd = getCloudCmd(); + + const current = {}; + currentFile.isCurrentFile(current); + + global.DOM = DOM; + global.CloudCmd = CloudCmd; + + t.ok(isContainClass.calledWith(current, _CURRENT_FILE), 'should call isContainClass'); + t.end(); +}); + function getCloudCmd({emit} = {}) { return { PREFIX: '', @@ -148,11 +192,13 @@ function getDOM({ getCurrentDirPath = sinon.stub(), getCurrentDirName = sinon.stub(), getByDataName = sinon.stub(), + isContainClass = sinon.stub(), } = {}) { return { getCurrentDirPath, getCurrentDirName, getByDataName, + isContainClass, CurrentInfo: { link, dirPath: '/',