UNPKG

twitch2ma

Version:

Twitch chat bot that runs commands on the MA GrandMA2 using Telnet.

26 lines (19 loc) 776 B
import _ = require("lodash"); export default class TwitchChatClient { onPrivmsgHandler: Function; onRegisterHandler: Function; onPrivmsg = jest.fn(handler => this.onPrivmsgHandler = handler); onRegister = jest.fn(handler => this.onRegisterHandler = handler); join = jest.fn(TwitchChatClient.joinImplementation()); quit = jest.fn().mockResolvedValue(null); say = jest.fn(); connect = jest.fn(() => { if(_.isFunction(this.onRegisterHandler)) { this.onRegisterHandler(); } return new Promise(resolve => resolve()) }); static forTwitchClient = jest.fn(() => new TwitchChatClient()); // Utility static joinImplementation: Function = jest.fn(() => () => new Promise(resolve => resolve())); }