summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-22 15:34:35 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-22 15:34:35 +0100
commit6653307fda137253cd10d4d4f6d2e010c1c0f604 (patch)
tree754d73e1dadc19e692bfce468e674cd66eff8a0a /test
parent642ba72a1d0680107357083a79560c2ccc931457 (diff)
downloadgitbook-6653307fda137253cd10d4d4f6d2e010c1c0f604.zip
gitbook-6653307fda137253cd10d4d4f6d2e010c1c0f604.tar.gz
gitbook-6653307fda137253cd10d4d4f6d2e010c1c0f604.tar.bz2
Add tests for context of filters
Diffstat (limited to 'test')
-rw-r--r--test/node_modules/gitbook-plugin-test-filters/index.js21
-rw-r--r--test/node_modules/gitbook-plugin-test-filters/package.json7
-rw-r--r--test/plugins.js27
3 files changed, 55 insertions, 0 deletions
diff --git a/test/node_modules/gitbook-plugin-test-filters/index.js b/test/node_modules/gitbook-plugin-test-filters/index.js
new file mode 100644
index 0000000..71f2752
--- /dev/null
+++ b/test/node_modules/gitbook-plugin-test-filters/index.js
@@ -0,0 +1,21 @@
+var should = require('should');
+
+module.exports = {
+ filters: {
+ // Simple test
+ hello: function(s) {
+ return 'Hello ' + s + '!';
+ },
+
+ // Test using the conetxt "this"
+ testContext: function(s) {
+ this.should.have.property('config');
+ this.should.have.property('log');
+ this.should.have.property('options');
+ this.should.have.property('resolve').which.is.a.function;
+ this.should.have.property('book').which.equal(this);
+
+ return 'Hello ' + s + '!';
+ }
+ }
+};
diff --git a/test/node_modules/gitbook-plugin-test-filters/package.json b/test/node_modules/gitbook-plugin-test-filters/package.json
new file mode 100644
index 0000000..d555d06
--- /dev/null
+++ b/test/node_modules/gitbook-plugin-test-filters/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "gitbook-plugin-test-filters",
+ "version": "1.0.0",
+ "engines": {
+ "gitbook": "*"
+ }
+} \ No newline at end of file
diff --git a/test/plugins.js b/test/plugins.js
index 576c96b..03bbc26 100644
--- a/test/plugins.js
+++ b/test/plugins.js
@@ -1,3 +1,4 @@
+var _ = require('lodash');
var path = require('path');
var mock = require('./mock');
@@ -124,5 +125,31 @@ describe('Plugins', function() {
});
});
});
+
+ describe('Filters', function() {
+ var plugin, filters;
+
+ before(function() {
+ plugin = new BookPlugin(book, 'test-filters');
+ return plugin.load(PLUGINS_ROOT)
+
+ .then(function() {
+ filters = plugin.getFilters();
+ });
+ });
+
+
+ it('should list all resources for website', function() {
+ _.size(filters).should.equal(2);
+ });
+
+ it('should correctly execute a filter', function() {
+ filters.hello('World').should.equal('Hello World!');
+ });
+
+ it('should correctly set contexts for filter', function() {
+ filters.testContext('Hello');
+ });
+ });
});