Class: Helper

Helper

Hubot Test Helper class


new Helper(scripts)

Creates a Helper instance

Parameters:
Name Type Argument Description
scripts botScript <repeatable>

the script modules to load into the Bot

Methods


<async> destroy()

Destroys the Bot.

Must be called when providing true in the httpd parameter when calling #init

Returns:
Type
Promise.<void>

emit(event, args)

Emits the provided event in the Bot

Parameters:
Name Type Argument Description
event string
args string <repeatable>
Returns:

null


<async> enter(user, room)

Triggers an EnterMessage at the provided room by the provided user

Parameters:
Name Type Description
user User
room string
Returns:
Type
Promise.<void>

<async> init( [httpd])

Initializes the Bot and prepares everything needed to receive messages

When providing true in httpd, #destroy must be called after the tests have completed.

Parameters:
Name Type Argument Default Description
httpd boolean <optional>
false

Option to start an HTTP server for the Bot

Returns:
Type
Promise.<void>

<async> leave(user, room)

Triggers a LeaveMessage at the provided room by the provided user

Parameters:
Name Type Description
user User
room string
Returns:
Type
Promise.<void>

messagesAt(room [, username])

Returns an array of arrays with: 0. The author's username

  1. The message
Parameters:
Name Type Argument Description
room string
username string <optional>

filter returned messages by author's username

Returns:
Type
Array.<Array.<string>>

on(event, listener)

Sets up a listener that will be called whenever the provided event is emitted by the Bot

Parameters:
Name Type Description
event string
listener function
Returns:

null


<async> sendMessage(user, room, message)

Sends a message by a user in a room

Parameters:
Name Type Description
user User
room string
message string
Returns:
Type
Promise.<void>

user(name [, alias])

Returns a new user that can interact with the Bot

Parameters:
Name Type Argument Default Description
name string
alias string <optional>
null

defaults to the provided name in low case

Returns:
Type
User