Skip to content

Support for pusher.bind and less dependencies

Compare
Choose a tag to compare
@nikolalsvk nikolalsvk released this 27 Jun 16:41
· 105 commits to master since this release

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.