diff options
Diffstat (limited to 'lib/plugins/__tests__')
-rw-r--r-- | lib/plugins/__tests__/findForBook.js | 19 | ||||
-rw-r--r-- | lib/plugins/__tests__/findInstalled.js | 25 | ||||
-rw-r--r-- | lib/plugins/__tests__/installPlugin.js | 29 | ||||
-rw-r--r-- | lib/plugins/__tests__/installPlugins.js | 30 | ||||
-rw-r--r-- | lib/plugins/__tests__/listDependencies.js | 38 | ||||
-rw-r--r-- | lib/plugins/__tests__/locateRootFolder.js | 10 | ||||
-rw-r--r-- | lib/plugins/__tests__/resolveVersion.js | 22 | ||||
-rw-r--r-- | lib/plugins/__tests__/sortDependencies.js | 42 | ||||
-rw-r--r-- | lib/plugins/__tests__/validatePlugin.js | 16 |
9 files changed, 0 insertions, 231 deletions
diff --git a/lib/plugins/__tests__/findForBook.js b/lib/plugins/__tests__/findForBook.js deleted file mode 100644 index d8af2e9..0000000 --- a/lib/plugins/__tests__/findForBook.js +++ /dev/null @@ -1,19 +0,0 @@ -var path = require('path'); - -var Book = require('../../models/book'); -var createNodeFS = require('../../fs/node'); -var findForBook = require('../findForBook'); - -describe('findForBook', function() { - var fs = createNodeFS( - path.resolve(__dirname, '../../..') - ); - var book = Book.createForFS(fs); - - it('should list default plugins', function() { - return findForBook(book) - .then(function(plugins) { - expect(plugins.has('fontsettings')).toBeTruthy(); - }); - }); -}); diff --git a/lib/plugins/__tests__/findInstalled.js b/lib/plugins/__tests__/findInstalled.js deleted file mode 100644 index 9377190..0000000 --- a/lib/plugins/__tests__/findInstalled.js +++ /dev/null @@ -1,25 +0,0 @@ -var path = require('path'); -var Immutable = require('immutable'); - -describe('findInstalled', function() { - var findInstalled = require('../findInstalled'); - - it('must list default plugins for gitbook directory', function() { - // Read gitbook-plugins from package.json - var pkg = require(path.resolve(__dirname, '../../../package.json')); - var gitbookPlugins = Immutable.Seq(pkg.dependencies) - .filter(function(v, k) { - return k.indexOf('gitbook-plugin') === 0; - }) - .cacheResult(); - - return findInstalled(path.resolve(__dirname, '../../../')) - .then(function(plugins) { - expect(plugins.size >= gitbookPlugins.size).toBeTruthy(); - - expect(plugins.has('fontsettings')).toBe(true); - expect(plugins.has('search')).toBe(true); - }); - }); - -}); diff --git a/lib/plugins/__tests__/installPlugin.js b/lib/plugins/__tests__/installPlugin.js deleted file mode 100644 index 0c1a346..0000000 --- a/lib/plugins/__tests__/installPlugin.js +++ /dev/null @@ -1,29 +0,0 @@ -var path = require('path'); - -var PluginDependency = require('../../models/pluginDependency'); -var Book = require('../../models/book'); -var NodeFS = require('../../fs/node'); -var installPlugin = require('../installPlugin'); - -var Parse = require('../../parse'); - -describe('installPlugin', function() { - var book; - - this.timeout(30000); - - before(function() { - var fs = NodeFS(path.resolve(__dirname, '../../../')); - var baseBook = Book.createForFS(fs); - - return Parse.parseConfig(baseBook) - .then(function(_book) { - book = _book; - }); - }); - - it('must install a plugin from NPM', function() { - var dep = PluginDependency.createFromString('ga'); - return installPlugin(book, dep); - }); -}); diff --git a/lib/plugins/__tests__/installPlugins.js b/lib/plugins/__tests__/installPlugins.js deleted file mode 100644 index 1a66f90..0000000 --- a/lib/plugins/__tests__/installPlugins.js +++ /dev/null @@ -1,30 +0,0 @@ -var path = require('path'); - -var Book = require('../../models/book'); -var NodeFS = require('../../fs/node'); -var installPlugins = require('../installPlugins'); - -var Parse = require('../../parse'); - -describe('installPlugins', function() { - var book; - - this.timeout(30000); - - before(function() { - var fs = NodeFS(path.resolve(__dirname, '../../../')); - var baseBook = Book.createForFS(fs); - - return Parse.parseConfig(baseBook) - .then(function(_book) { - book = _book; - }); - }); - - it('must install all plugins from NPM', function() { - return installPlugins(book) - .then(function(n) { - expect(n).toBe(2); - }); - }); -}); diff --git a/lib/plugins/__tests__/listDependencies.js b/lib/plugins/__tests__/listDependencies.js deleted file mode 100644 index 940faba..0000000 --- a/lib/plugins/__tests__/listDependencies.js +++ /dev/null @@ -1,38 +0,0 @@ -var PluginDependency = require('../../models/pluginDependency'); -var listDependencies = require('../listDependencies'); -var toNames = require('../toNames'); - -describe('listDependencies', function() { - it('must list default', function() { - var deps = PluginDependency.listFromString('ga,great'); - var plugins = listDependencies(deps); - var names = toNames(plugins); - - expect(names).toEqual([ - 'ga', 'great', - 'highlight', 'search', 'lunr', 'sharing', 'fontsettings', - 'theme-default' ]); - }); - - it('must list from array with -', function() { - var deps = PluginDependency.listFromString('ga,-great'); - var plugins = listDependencies(deps); - var names = toNames(plugins); - - expect(names).toEqual([ - 'ga', - 'highlight', 'search', 'lunr', 'sharing', 'fontsettings', - 'theme-default' ]); - }); - - it('must remove default plugins using -', function() { - var deps = PluginDependency.listFromString('ga,-search'); - var plugins = listDependencies(deps); - var names = toNames(plugins); - - expect(names).toEqual([ - 'ga', - 'highlight', 'lunr', 'sharing', 'fontsettings', - 'theme-default' ]); - }); -}); diff --git a/lib/plugins/__tests__/locateRootFolder.js b/lib/plugins/__tests__/locateRootFolder.js deleted file mode 100644 index bb414a3..0000000 --- a/lib/plugins/__tests__/locateRootFolder.js +++ /dev/null @@ -1,10 +0,0 @@ -var path = require('path'); -var locateRootFolder = require('../locateRootFolder'); - -describe('locateRootFolder', function() { - it('should correctly resolve the node_modules for gitbook', function() { - expect(locateRootFolder()).toBe( - path.resolve(__dirname, '../../../') - ); - }); -}); diff --git a/lib/plugins/__tests__/resolveVersion.js b/lib/plugins/__tests__/resolveVersion.js deleted file mode 100644 index 1877c9e..0000000 --- a/lib/plugins/__tests__/resolveVersion.js +++ /dev/null @@ -1,22 +0,0 @@ -var PluginDependency = require('../../models/pluginDependency'); -var resolveVersion = require('../resolveVersion'); - -describe('resolveVersion', function() { - it('must skip resolving and return non-semver versions', function() { - var plugin = PluginDependency.createFromString('ga@git+ssh://samy@github.com/GitbookIO/plugin-ga.git'); - - return resolveVersion(plugin) - .then(function(version) { - expect(version).toBe('git+ssh://samy@github.com/GitbookIO/plugin-ga.git'); - }); - }); - - it('must resolve a normal plugin dependency', function() { - var plugin = PluginDependency.createFromString('ga@>0.9.0 < 1.0.1'); - - return resolveVersion(plugin) - .then(function(version) { - expect(version).toBe('1.0.0'); - }); - }); -}); diff --git a/lib/plugins/__tests__/sortDependencies.js b/lib/plugins/__tests__/sortDependencies.js deleted file mode 100644 index 87df477..0000000 --- a/lib/plugins/__tests__/sortDependencies.js +++ /dev/null @@ -1,42 +0,0 @@ -var PluginDependency = require('../../models/pluginDependency'); -var sortDependencies = require('../sortDependencies'); -var toNames = require('../toNames'); - -describe('sortDependencies', function() { - it('must load themes after plugins', function() { - var allPlugins = PluginDependency.listFromArray([ - 'hello', - 'theme-test', - 'world' - ]); - - var sorted = sortDependencies(allPlugins); - var names = toNames(sorted); - - expect(names).toEqual([ - 'hello', - 'world', - 'theme-test' - ]); - }); - - it('must keep order of themes', function() { - var allPlugins = PluginDependency.listFromArray([ - 'theme-test', - 'theme-test1', - 'hello', - 'theme-test2', - 'world' - ]); - var sorted = sortDependencies(allPlugins); - var names = toNames(sorted); - - expect(names).toEqual([ - 'hello', - 'world', - 'theme-test', - 'theme-test1', - 'theme-test2' - ]); - }); -});
\ No newline at end of file diff --git a/lib/plugins/__tests__/validatePlugin.js b/lib/plugins/__tests__/validatePlugin.js deleted file mode 100644 index 635423c..0000000 --- a/lib/plugins/__tests__/validatePlugin.js +++ /dev/null @@ -1,16 +0,0 @@ -var Promise = require('../../utils/promise'); -var Plugin = require('../../models/plugin'); -var validatePlugin = require('../validatePlugin'); - -describe('validatePlugin', function() { - it('must not validate a not loaded plugin', function() { - var plugin = Plugin.createFromString('test'); - - return validatePlugin(plugin) - .then(function() { - throw new Error('Should not be validate'); - }, function(err) { - return Promise(); - }); - }); -}); |