Adapt findInstalled for unit tests

This commit is contained in:
Samy Pesse
2016-10-12 11:04:09 +02:00
parent c71da9955e
commit 5fed4e1ced
3 changed files with 14 additions and 9 deletions
@@ -17,7 +17,7 @@ describe('findInstalled', function() {
.then(function(plugins) {
expect(plugins.size >= gitbookPlugins.size).toBeTruthy();
expect(plugins.has('fontsettings')).toBe(true);
expect(plugins.has('highlight')).toBe(true);
expect(plugins.has('search')).toBe(true);
});
});
@@ -41,9 +41,14 @@ function readModule(modulePath, depth, parent) {
* @param {String} folder
* @param {Number} depth
* @param {String} parent
* @return {OrderedMap<String:Plugin>}
* @return {Promise<OrderedMap<String:Plugin>>} plugins
*/
function findInstalled(folder, depth = 0, parent = null) {
// When tetsing with mock-fs
if (!folder) {
return Promise(OrderedMap());
}
// Search for gitbook-plugins in node_modules folder
const node_modules = path.join(folder, 'node_modules');
+7 -7
View File
@@ -15,13 +15,13 @@ function isModuleNotFound(err) {
}
/**
Load a plugin in a book
@param {Book} book
@param {Plugin} plugin
@param {String} pkgPath (optional)
@return {Promise<Plugin>}
*/
* Load a plugin in a book
*
* @param {Book} book
* @param {Plugin} plugin
* @param {String} pkgPath (optional)
* @return {Promise<Plugin>}
*/
function loadPlugin(book, plugin) {
const logger = book.getLogger();