Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ExpectedMessage

Class that wraps expectedResponseCollections for comparison against an outgoing message. One instance of ExpectedMessage represents one response from the bot.

Hierarchy

  • ExpectedMessage

Index

Constructors

constructor

Properties

Private expectedResponseCollection

expectedResponseCollection: PossibleExpectedMessageCollections

set of possible responses, chosen at random. If the collection size is 1, then there is only one response that is expected

Private internalExpectation

internalExpectation: BotTesterExpectation

Methods

checkForMessageMatch

  • checkForMessageMatch(outgoingMessage: IMessage): void
  • routes the outgoingMessage to the proper comparison method based on the expectedResponseCollection. This switch based method exists due to typescript's lack of polymorphism support.

    Parameters

    • outgoingMessage: IMessage

      outgoing message that is being compared

    Returns void

Private checkMessageTextForExactStringMatch

  • checkMessageTextForExactStringMatch(outgoingMessage: IMessage, expectedResponseStrings: string[]): void
  • Asserts that outgoingMessage.text is within the expectedResponseStrings collection

    Parameters

    • outgoingMessage: IMessage

      outgoing message being compared

    • expectedResponseStrings: string[]

      collection of possible string values for comparison

    Returns void

Private checkMessageTextForRegex

  • checkMessageTextForRegex(outgoingMessage: IMessage): void
  • Assumes the expectedResponseCollection are regexs. Asserts that outgoingMessage.text matches at least of the regexs in expectedResponseCollection

    Parameters

    • outgoingMessage: IMessage

      outgoing message being compared

    Returns void

Private deepMessageMatchCheck

  • deepMessageMatchCheck(outgoingMessage: IMessage): void
  • Assumes the expectedResponseCollection is an IMessage[]. Asserts that at least one IMessage in expectedResponseCollection is fully contained within the outgoingMessage (i.e. the outgoingMessage {type: 'message', text:'hello'}) would be matched successfully against {type: 'message', text: 'hello', user: { id: user1 }} because the outgoing message is contained within the response. It would not successfulyl be matched against {text: 'hello', user: { id: user1 }} because the expected response is missing { type: 'message' }

    Parameters

    • outgoingMessage: IMessage

      outgoing message being compared

    Returns void

toString

  • toString(): string