UNPKG

pusher-js-mock

Version:

Mock Pusher.js in your JavaScript tests with ease

48 lines (47 loc) 1.73 kB
import { PusherChannelMock } from "."; export interface IPusherMockOptions { authorizer: (channel: PusherChannelMock) => { authorize: (socketId: string, callback: (error: boolean, authInfo: any) => void) => void; }; } /** Class representing fake Pusher Client. */ declare class PusherMock { id: string | undefined; info: Record<string, any> | undefined; clientKey: string | undefined; config: IPusherMockOptions | undefined; connection: any; channels: import("./pusher-js-mock-instance").IChannels; channel: (name: string, client?: PusherMock) => any; /** Initialize PusherMock */ constructor(clientKey?: string, config?: IPusherMockOptions); setAuthInfo(errored: boolean, auth: any): void; /** * Mock subscribing to a channel. * @param {String} name - name of the channel. * @returns {PusherChannelMock} PusherChannelMock object that represents channel */ subscribe(name: string): any; /** * Unsubscribe from a mocked channel. * @param {String} name - name of the channel. */ unsubscribe(name: string): void; /** * Bind a callback to an event on all channels * @param {String} name - name of the event to bind to. * @param {Function} callback - callback to be called on event. */ bind(name: string, callback: () => void): void; /** * Unbind a callback from an event on all channels * @param {String} name - name of the event to unbind from. * @param {Function} callback - callback to be called on event. */ unbind(name: string, callback: () => void): void; /** * Returns a list of all channels */ allChannels(): any[]; } export default PusherMock;