summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/mock.js8
-rw-r--r--test/plugins.js38
2 files changed, 39 insertions, 7 deletions
diff --git a/test/mock.js b/test/mock.js
index ce4dca5..701df99 100644
--- a/test/mock.js
+++ b/test/mock.js
@@ -78,8 +78,14 @@ function outputDefaultBook(Output, files, summary, opts) {
});
}
+// Log an error
+function logError(err) {
+ console.log(err.stack || err);
+}
+
module.exports = {
setupBook: setupBook,
setupDefaultBook: setupDefaultBook,
- outputDefaultBook: outputDefaultBook
+ outputDefaultBook: outputDefaultBook,
+ logError: logError
};
diff --git a/test/plugins.js b/test/plugins.js
index 81c099e..47f9314 100644
--- a/test/plugins.js
+++ b/test/plugins.js
@@ -1,6 +1,7 @@
var mock = require('./mock');
var registry = require('../lib/plugins/registry');
var Output = require('../lib/output/base');
+var PluginsManager = require('../lib/plugins');
describe('Plugins', function() {
var book;
@@ -19,6 +20,15 @@ describe('Plugins', function() {
});
});
+ describe('Loading', function() {
+ it('should load default plugins', function() {
+ return mock.outputDefaultBook(Output)
+ .then(function(output) {
+ output.plugins.count().should.be.greaterThan(0);
+ });
+ });
+ });
+
describe('Installation', function() {
it('should install a plugin from NPM without a specific version', function() {
return registry.install(book, 'ga')
@@ -29,15 +39,31 @@ describe('Plugins', function() {
return registry.install(book, 'ga', '1.0.0')
.should.be.fulfilled();
});
- });
- describe('Loading', function() {
- it('should load default plugins', function() {
- return mock.outputDefaultBook(Output)
- .then(function(output) {
- output.plugins.count().should.be.greaterThan(0);
+ it('should correctly install all dependencies (if none)', function() {
+ return mock.setupBook({})
+ .then(function(book) {
+ var plugins = new PluginsManager(book);
+ return plugins.install()
+ .should.be.fulfilledWith(0);
});
});
+
+ it('should correctly install all dependencies (if any)', function() {
+ return mock.setupBook({
+ 'book.json': {
+ plugins: ['ga']
+ }
+ })
+ .then(function(book) {
+ return book.config.load()
+ .then(function() {
+ var plugins = new PluginsManager(book);
+ return plugins.install();
+ });
+ })
+ .should.be.fulfilledWith(1);
+ });
});
});