UNPKG

1.64 kBTypeScriptView Raw
1/// <reference types="bluebird" />
2import * as Promise from 'bluebird';
3import { IMessage, UniversalBot } from 'botbuilder';
4import { IConfig } from './config';
5import { ExpectedMessage } from './ExpectedMessage';
6export declare type botToUserMessageCheckerFunction = (msg: IMessage | IMessage[]) => void;
7/**
8 * Handles sending messages to bot, intercepts the responses, and compares the response to the expected responses for the particular test
9 * step
10 */
11export declare class MessageService {
12 private bot;
13 private botToUserMessageChecker;
14 private config;
15 constructor(bot: UniversalBot, config: IConfig);
16 /**
17 * Sends message to bot and sets the expectations for the responses.
18 *
19 * @param message message to send to bot
20 * @param expectedResponses expected responses
21 */
22 sendMessageToBot(message: IMessage, expectedResponses: ExpectedMessage[], ignoreOrder?: boolean): Promise<void>;
23 /**
24 * Sets the current response expectation function for the message service. This allows the botToUserMessageChecker property to be
25 * updated within a closure with the proper expectedResponses. The promise that is returned will only resolve when all responses have
26 * been seen. Many tests will hang here and fail if an expected response is never received
27 *
28 * @param expectedResponses collection of expected responses for a particular step
29 */
30 private setBotToUserMessageChecker(expectedResponses, outgoingMessageComparator);
31 /**
32 * Inject middleware to intercept outgoing messages to check their content
33 */
34 private applyOutgoingMessageListener();
35}