Skip to content

Commit 426510c

Browse files
committed
Add databaseAdapter test
1 parent bcccf2c commit 426510c

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

spec/AdapterLoader.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,25 @@ describe('AdapterLoader', () => {
142142
}).not.toThrow();
143143
});
144144

145+
it('should load custom database adapter from config', done => {
146+
const adapterPath = require('path').resolve('./spec/support/MockDatabaseAdapter');
147+
const options = {
148+
databaseURI: 'oracledb://user:password@localhost:1521/freepdb1',
149+
collectionPrefix: '',
150+
};
151+
const databaseAdapterOptions = {
152+
adapter: adapterPath,
153+
options,
154+
};
155+
expect(() => {
156+
const databaseAdapter = loadAdapter(databaseAdapterOptions);
157+
expect(databaseAdapter).not.toBe(undefined);
158+
expect(databaseAdapter.options).toEqual(options);
159+
expect(databaseAdapter.getDatabaseURI()).toEqual(options.databaseURI);
160+
}).not.toThrow();
161+
done();
162+
});
163+
145164
it('should load file adapter from direct passing', done => {
146165
spyOn(console, 'warn').and.callFake(() => {});
147166
const mockFilesAdapter = new MockFilesAdapter('key', 'secret', 'bucket');

spec/support/MockDatabaseAdapter.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = function (options) {
2+
return {
3+
options: options,
4+
send: function () {},
5+
getDatabaseURI: function () {
6+
return options.databaseURI;
7+
},
8+
};
9+
};

0 commit comments

Comments
 (0)