Skip to content

botmasterai/botmaster-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Utilities for testing botmaster

Quick start example

For an example please see the tests in this repo: https://github.com/botmasterai/botmaster-fulfill/blob/master/src/tests/fulfill-e2e.js

Usage

respond

have bot master response done with a text. Chain it by calling it response(botmaster)(text)

Parameters

  • botmaster object botmaster to work with
  • text String bot text to send

incomingMessage

generate a new telegram incoming message for use with botmaster

Parameters

  • text string?= 'hi' optional - the users text

Returns Object a mock telegram incoming message to use with telegramMock.sendMessage

incomingUpdate

generate an incoming update

Parameters

Returns Object mock botmaster update after update handler

outgoingMessage

generate an outgoing message

Parameters

Returns Object message to send with bot.sendMessage

telegramMock

A chainable mock for telegram that can send and expect messages. Construct it by calling it with these params.

Parameters

  • botmaster Object the botmaster object being tested. we use this to get the app for use with supertest.
  • mock Object? a nock scope

Returns Object mock object with methods

sendUpdate

mock telegram sending botmaster an update

Parameters

  • update object telegram update
  • cb Function error-first callback with response object from botmaster

Returns Object the telegraMock object for chaining

expect

expect botmaster to send certain responses

Parameters

  • responses Array a series of botmaster responses to expect in order
  • cb Function error-first callback

Returns Object the telegraMock object for chaining

cleanAll

sugar syntax for nock.cleanAll() to remove any existing mocks

About

helper utilities for testing botmaster

Resources

License

Stars

Watchers

Forks

Packages

No packages published