Skip to content

Commit d3e6c0d

Browse files
authored
Adds test for #3544 (#3545)
1 parent b4e27e1 commit d3e6c0d

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

spec/AdapterLoader.spec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var loadAdapter = require("../src/Adapters/AdapterLoader").loadAdapter;
33
var FilesAdapter = require("parse-server-fs-adapter").default;
44
var S3Adapter = require("parse-server-s3-adapter").default;
55
var ParsePushAdapter = require("parse-server-push-adapter").default;
6+
const Config = require('../src/Config');
67

78
describe("AdapterLoader", ()=>{
89

@@ -118,6 +119,30 @@ describe("AdapterLoader", ()=>{
118119
done();
119120
});
120121

122+
it("should load custom push adapter from string (#3544)", (done) => {
123+
var adapterPath = require('path').resolve("./spec/MockPushAdapter");
124+
var options = {
125+
ios: {
126+
bundleId: 'bundle.id'
127+
}
128+
}
129+
const pushAdapterOptions = {
130+
adapter: adapterPath,
131+
options
132+
};
133+
expect(() => {
134+
reconfigureServer({
135+
push: pushAdapterOptions,
136+
}).then(() => {
137+
const config = new Config(Parse.applicationId);
138+
const pushAdapter = config.pushWorker.adapter;
139+
expect(pushAdapter.getValidPushTypes()).toEqual(['ios']);
140+
expect(pushAdapter.options).toEqual(pushAdapterOptions);
141+
done();
142+
});
143+
}).not.toThrow();
144+
});
145+
121146
it("should load S3Adapter from direct passing", (done) => {
122147
var s3Adapter = new S3Adapter("key", "secret", "bucket")
123148
expect(() => {

spec/MockPushAdapter.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+
getValidPushTypes: function() {
6+
return Object.keys(options.options);
7+
}
8+
};
9+
};

0 commit comments

Comments
 (0)