How to use the @slack/rtm-api.RTMClient.mockImplementation function in @slack/rtm-api

To help you get started, we’ve selected a few @slack/rtm-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Yoctol / bottender / packages / bottender / src / slack / __tests__ / SlackBot.spec.ts View on Github external
it('should work', () => {
    const bot = new SlackBot({
      accessToken: 'zzzzzZZZZZ',
    });
    const start = jest.fn();
    const on = jest.fn();
    const handler = jest.fn();

    RTMClient.mockImplementation(() => ({
      on,
      start,
    }));

    bot.createRequestHandler = jest.fn(() => handler);

    bot.createRtmRuntime();

    expect(on).toBeCalledWith('message', handler);
    expect(start).toHaveBeenCalledTimes(1);
  });
});

@slack/rtm-api

Official library for using the Slack Platform's Real Time Messaging API

MIT
Latest version published 3 months ago

Package Health Score

95 / 100
Full package analysis