diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/helper.js | 3 | ||||
-rw-r--r-- | test/plugins.js | 27 | ||||
-rw-r--r-- | test/plugins/resources/index.js | 7 | ||||
-rw-r--r-- | test/plugins/resources/package.json | 9 |
4 files changed, 45 insertions, 1 deletions
diff --git a/test/helper.js b/test/helper.js index fbdd85c..5e16bc0 100644 --- a/test/helper.js +++ b/test/helper.js @@ -5,6 +5,7 @@ var _ = require('lodash'); var fsUtil = require("../lib/utils/fs"); var Book = require('../').Book; +var LOG_LEVELS = require('../').LOG_LEVELS; // Nicety for mocha / Q global.qdone = function qdone(promise, done) { @@ -38,7 +39,7 @@ global.books = _.chain(books) .map(function(book) { if (book.indexOf("test") !== 0) return null; return new Book(path.join(__dirname, './fixtures/', book), { - logLevel: Book.LOG_LEVELS.DISABLED + logLevel: LOG_LEVELS.DISABLED }); }) .compact() diff --git a/test/plugins.js b/test/plugins.js index 78f5b44..f72f719 100644 --- a/test/plugins.js +++ b/test/plugins.js @@ -36,6 +36,33 @@ describe('Plugins', function () { }); }); + describe('resources plugin', function() { + var plugin = new Plugin(books[0], "resources"); + plugin.load("./resources", PLUGINS_ROOT); + + before(function(done) { + qdone(books[0].plugins.load(plugin), done); + }); + + it('should valid a plugin', function() { + assert(plugin.isValid()); + }); + + it('should return a valid list of resources', function(done) { + qdone( + plugin.getResources() + .then(function(resources) { + assert.equal(resources["js"].length, 1); + }), + done); + }); + + it('should extend books plugins', function() { + var resources = books[0].plugins.resources; + assert.equal(resources["js"].length, 1); + }); + }); + describe('filters', function() { var plugin = new Plugin(books[0], "filters"); plugin.load("./filters", PLUGINS_ROOT); diff --git a/test/plugins/resources/index.js b/test/plugins/resources/index.js new file mode 100644 index 0000000..68b3c39 --- /dev/null +++ b/test/plugins/resources/index.js @@ -0,0 +1,7 @@ +module.exports = { + book: { + js: [ + "https://cdn.mathjax.org/mathjax/2.4-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" + ] + } +}; diff --git a/test/plugins/resources/package.json b/test/plugins/resources/package.json new file mode 100644 index 0000000..ab4320d --- /dev/null +++ b/test/plugins/resources/package.json @@ -0,0 +1,9 @@ +{ + "name": "gitbook-plugin-resources", + "description": "Test resources plugin", + "main": "index.js", + "version": "0.0.1", + "engines": { + "gitbook": "*" + } +}
\ No newline at end of file |