Support for pusher.bind and less dependencies
The new version of pusher-js-mock brings a couple of changes
pusher.bind() π
You can now test pusher.bind()
that will bind a callback to all your channels.
This is inspired by the issue raised by @snaptopixel in #23 and by the Pusher JS docs describing how to use this.
Here's an example on how to use it:
describe("#bind", () => {
it("binds event to all channels", () => {
const listener = jest.fn();
const myChannel = pusherMock.channel("my-channel");
const myOtherChannel = pusherMock.channel("my-other-channel");
const myThirdChannel = pusherMock.channel("my-third-channel");
pusherMock.bind("test-event", listener);
myChannel.emit("test-event");
expect(listener).toHaveBeenCalledTimes(1);
myOtherChannel.emit("test-event");
expect(listener).toHaveBeenCalledTimes(2);
myThirdChannel.emit("test-event");
expect(listener).toHaveBeenCalledTimes(3);
});
});
Less dependencies π¦
Yep, we removed pusher-js
and pusher-js-mock
from development dependencies of the gem.
It should now be lightweight and it won't interfere with any of the versions of pusher-js
you have.
This was largely inspired by #25.