mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-19 17:15:24 +00:00
Adapt findInstalled for unit tests
This commit is contained in:
@@ -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');
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user