-
Notifications
You must be signed in to change notification settings - Fork 11
/
config.ts
59 lines (48 loc) · 1.43 KB
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { IAddress, IMessage } from 'botbuilder';
import * as fs from 'fs';
/**
* Returns true if a message
*/
export type MessageFilter = (message: IMessage) => boolean;
export interface IConfig {
/**
* timeout in milliseconds before a BotTester runner will fail a test (when not overriden)
*/
timeout?: number;
/**
* default address bot will use for all communication (when not overriden)
*/
defaultAddress?: IAddress;
/**
* ignores typing event messages
*/
ignoreTypingEvent?: boolean;
/**
* ignores end of conversation event messages
*/
ignoreEndOfConversationEvent?: boolean;
/**
* filters for messages that the BotTester framework should use
*/
messageFilters?: MessageFilter[];
}
const configFilePath = `bot-tester.json`;
const configFileExists = fs.existsSync(configFilePath);
/**
* default value for timeout. If config/options are set to this value, no timeout will be used
*/
export const NO_TIMEOUT = -1;
let configInternal: IConfig = {
timeout: NO_TIMEOUT,
defaultAddress: {
channelId: 'console',
user: { id: 'user1', name: 'user1' },
bot: { id: 'bot', name: 'Bot' },
conversation: { id: 'user1Conversation' }
}
};
if (configFileExists) {
configInternal = JSON.parse(fs.readFileSync(configFilePath, { encoding: 'utf8' }));
}
configInternal.messageFilters = [];
export const config = configInternal;