Skip to content

Commit

Permalink
fix: persist previous options
Browse files Browse the repository at this point in the history
  • Loading branch information
kamalbennani-aircall committed Nov 29, 2023
1 parent de37543 commit 3fc566e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
17 changes: 17 additions & 0 deletions spec/javascripts/unit/core/pusher_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,23 @@ describe("Pusher", function() {
"channel"
);
});

it('should keep the persist the previous options', () => {
var authorizeSpy = jasmine.createSpy("authorizeSpy");
const options = {
cluster: "mt1",
enableStats: true,
channelAuthorization: {
customHandler: authorizeSpy
}
};

var pusher = new Pusher("foo", options);
pusher.connect();
pusher.switchCluster({ appKey: 'bar', cluster: 'us3' });

expect(pusher.options).toEqual({ ...options, cluster: 'us3' });
})
})

describe("#unsubscribe", function() {
Expand Down
3 changes: 2 additions & 1 deletion src/core/pusher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export default class Pusher {
checkAppKey(app_key);
validateOptions(options);
this.key = app_key;
this.config = getConfig(options, this);
this.options = options;
this.config = getConfig(this.options, this);

this.channels = Factory.createChannels();
this.global_emitter = new EventsDispatcher();
Expand Down

0 comments on commit 3fc566e

Please sign in to comment.