Skip to content

Commit

Permalink
pass global config to subclass (#449)
Browse files Browse the repository at this point in the history
2 parameters can be set by the caller

```
import Pusher from 'pusher-js;
Pusher.logToConsole;
```

etc

We need to pass these properties on to the subclass
  • Loading branch information
James Lees authored Apr 27, 2020
1 parent 1753822 commit 139bcc3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/javascripts/unit/core/pusher_with_encryption_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var Pusher = require('core/pusher').default;
var PusherWithEncryption = require('core/pusher-with-encryption').default;

describe('PusherWithEncryption', function() {
it('should pass logToConsole config to parent class', function() {
PusherWithEncryption.logToConsole = true;
let pusher = new PusherWithEncryption('key');
expect(Pusher.logToConsole).toEqual(true);
});
it('should pass log function to parent class', function() {
let logFn = jasmine.createSpy('logFn');
PusherWithEncryption.log = logFn
let pusher = new PusherWithEncryption('key');
expect(logFn).toHaveBeenCalled();
});
});
3 changes: 3 additions & 0 deletions src/core/pusher-with-encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import * as nacl from 'tweetnacl';

export default class PusherWithEncryption extends Pusher {
constructor(app_key: string, options?: Options) {
Pusher.logToConsole = PusherWithEncryption.logToConsole;
Pusher.log = PusherWithEncryption.log;

options = options || {};
options.nacl = nacl;
super(app_key, options);
Expand Down

0 comments on commit 139bcc3

Please sign in to comment.