|
18 | 18 | const assert = require('assert'); |
19 | 19 | const Client = require('../lib/client.js'); |
20 | 20 | const nock = require('./nock.js'); |
| 21 | +const path = require('path'); |
21 | 22 | const stream = require('stream'); |
22 | 23 | const testPlugin = require('./fixtures/testplugins.js'); |
23 | 24 | const uuidv4 = require('uuid/v4'); // random |
@@ -86,6 +87,29 @@ describe('CloudantClient', function() { |
86 | 87 | }); |
87 | 88 |
|
88 | 89 | describe('plugin support', function() { |
| 90 | + it('get plugin path by name', function() { |
| 91 | + var cloudantClient = new Client(); |
| 92 | + assert.equal(cloudantClient._buildPluginPath('dummy-plugin'), '../plugins/dummy-plugin'); |
| 93 | + }); |
| 94 | + |
| 95 | + it('get plugin path by relative path', function() { |
| 96 | + var cloudantClient = new Client(); |
| 97 | + assert.equal(cloudantClient._buildPluginPath('./dummy-plugin'), path.join(process.cwd(), 'dummy-plugin')); |
| 98 | + }); |
| 99 | + |
| 100 | + it('get plugin path by absolute path', function() { |
| 101 | + var cloudantClient = new Client(); |
| 102 | + assert.equal(cloudantClient._buildPluginPath('/plugins/dummy-plugin'), '/plugins/dummy-plugin'); |
| 103 | + }); |
| 104 | + |
| 105 | + it('load plugin from custom path', function() { |
| 106 | + let ownPlugin = 'test/fixtures/testplugin.js'; |
| 107 | + var cloudantClient = new Client({ |
| 108 | + plugins: [ ownPlugin ] |
| 109 | + }); |
| 110 | + assert.equal(cloudantClient._plugins.length, 1); |
| 111 | + }); |
| 112 | + |
89 | 113 | it('adds cookie authentication plugin if no other plugins are specified', function() { |
90 | 114 | var cloudantClient = new Client(); |
91 | 115 | assert.equal(cloudantClient._plugins.length, 1); |
|
0 commit comments