botium-core 1.13.2 → 1.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/.eslintrc.js +6 -3
  2. package/dist/botium-cjs.js +214 -61
  3. package/dist/botium-cjs.js.map +1 -1
  4. package/dist/botium-es.js +213 -61
  5. package/dist/botium-es.js.map +1 -1
  6. package/package.json +3 -1
  7. package/src/Capabilities.js +2 -1
  8. package/src/containers/plugins/SimpleRestContainer.js +20 -16
  9. package/src/grid/inbound/proxy.js +2 -1
  10. package/src/scripting/Convo.js +16 -10
  11. package/src/scripting/MatchFunctions.js +10 -0
  12. package/src/scripting/ScriptingProvider.js +106 -37
  13. package/src/scripting/logichook/LogicHookConsts.js +1 -1
  14. package/src/scripting/logichook/asserter/WerAsserter.js +59 -0
  15. package/src/scripting/logichook/logichooks/UpdateCustomLogicHook.js +3 -2
  16. package/test/compiler/compilercsv.spec.js +104 -3
  17. package/test/compiler/compilerjson.spec.js +0 -2
  18. package/test/compiler/compilerxlsx.spec.js +1 -1
  19. package/test/compiler/convos/csv/utterances_liveperson2.csv +12 -0
  20. package/test/connectors/simplerest.spec.js +1012 -969
  21. package/test/convo/fillAndApplyScriptingMemory.spec.js +804 -785
  22. package/test/convo/partialconvo.spec.js +345 -339
  23. package/test/driver/capabilities.spec.js +156 -151
  24. package/test/logichooks/hookfromsrc.spec.js +79 -73
  25. package/test/plugins/plugins.spec.js +44 -42
  26. package/test/scripting/asserters/buttonsAsserter.spec.js +257 -240
  27. package/test/scripting/asserters/cardsAsserter.spec.js +214 -212
  28. package/test/scripting/asserters/convos/wer_threshold_nok.yml +7 -0
  29. package/test/scripting/asserters/convos/wer_threshold_ok.yml +7 -0
  30. package/test/scripting/asserters/intentConfidenceAsserter.spec.js +34 -35
  31. package/test/scripting/asserters/jsonpathAsserter.spec.js +307 -308
  32. package/test/scripting/asserters/mediaAsserter.spec.js +236 -234
  33. package/test/scripting/asserters/werAsserter.spec.js +51 -0
  34. package/test/scripting/logichooks/setClearScriptingMemory.spec.js +202 -192
  35. package/test/scripting/matching/matchingmode.spec.js +306 -258
  36. package/test/scripting/scriptingProvider.spec.js +666 -633
  37. package/test/scripting/scriptingmemory/fillScriptingMemoryFromFile.spec.js +299 -281
  38. package/test/scripting/scriptingmemory/useScriptingMemoryForAssertion.spec.js +94 -80
  39. package/test/scripting/userinputs/defaultUserInputs.spec.js +233 -127
  40. package/test/scripting/userinputs/mediaInputConvos.spec.js +409 -403
  41. package/test/scripting/utteranceexpansion/associateByIndex.spec.js +259 -0
  42. package/test/scripting/utteranceexpansion/convos/associate_utterances_by_index.json +33 -0
  43. package/test/scripting/utteranceexpansion/convos/media.convo.txt +19 -0
  44. package/test/scripting/utteranceexpansion/files/step0voice0.wav +0 -0
  45. package/test/scripting/utteranceexpansion/files/step0voice1.wav +0 -0
  46. package/test/scripting/utteranceexpansion/files/step0voice2.wav +0 -0
  47. package/test/scripting/utteranceexpansion/files/step1voice0.wav +0 -0
  48. package/test/scripting/utteranceexpansion/files/step2voice0.wav +0 -0
  49. package/test/scripting/utteranceexpansion/files/step2voice1.wav +0 -0
  50. package/test/scripting/utteranceexpansion/files/step2voice2.wav +0 -0
  51. package/test/scripting/utteranceexpansion/files/step2voice4.wav +0 -0
  52. package/test/scripting/utteranceexpansion/files/step2voice5.wav +0 -0
  53. package/test/security/allowUnsafe.spec.js +274 -268
  54. package/test/utils.spec.js +40 -38
@@ -6,297 +6,345 @@ const Capabilities = require('../../../').Capabilities
6
6
  const echoConnector = ({ queueBotSays }) => {
7
7
  return {
8
8
  UserSays (msg) {
9
- const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: `You said: ${msg.messageText}` }
9
+ const botMsg = {
10
+ sender: 'bot',
11
+ sourceData: msg.sourceData,
12
+ messageText: `You said: ${msg.messageText}`
13
+ }
10
14
  queueBotSays(botMsg)
11
15
  }
12
16
  }
13
17
  }
14
18
 
15
- describe('matching.matchingmode.general', function () {
16
- beforeEach(async function () {
17
- const myCaps = {
18
- [Capabilities.PROJECTNAME]: 'matching.matchingmode',
19
- [Capabilities.CONTAINERMODE]: echoConnector,
20
- [Capabilities.SCRIPTING_MATCHING_MODE]: 'include'
21
- }
22
- const driver = new BotDriver(myCaps)
23
- this.compiler = driver.BuildCompiler()
24
- this.container = await driver.Build()
25
- })
26
- afterEach(async function () {
27
- this.container && await this.container.Clean()
28
- })
19
+ describe('scripting.matching.matchingmode', function () {
20
+ describe('general', function () {
21
+ beforeEach(async function () {
22
+ const myCaps = {
23
+ [Capabilities.PROJECTNAME]: 'matching.matchingmode',
24
+ [Capabilities.CONTAINERMODE]: echoConnector,
25
+ [Capabilities.SCRIPTING_MATCHING_MODE]: 'include'
26
+ }
27
+ const driver = new BotDriver(myCaps)
28
+ this.compiler = driver.BuildCompiler()
29
+ this.container = await driver.Build()
30
+ })
31
+ afterEach(async function () {
32
+ this.container && await this.container.Clean()
33
+ })
29
34
 
30
- it('should match int response with string', async function () {
31
- assert.isTrue(this.compiler.Match(123, '123'))
32
- })
35
+ it('should match int response with string', async function () {
36
+ assert.isTrue(this.compiler.Match(123, '123'))
37
+ })
33
38
 
34
- it('should match JSON response with messageText and a string', async function () {
35
- assert.isTrue(this.compiler.Match({ messageText: 123 }, '123'))
36
- })
39
+ it('should match JSON response with messageText and a string', async function () {
40
+ assert.isTrue(this.compiler.Match({ messageText: 123 }, '123'))
41
+ })
37
42
 
38
- it('should match JSON response with toString', async function () {
39
- assert.isTrue(this.compiler.Match({ somethingElse: '123' }, '"somethingElse":"123"'))
43
+ it('should match JSON response with toString', async function () {
44
+ assert.isTrue(this.compiler.Match({ somethingElse: '123' }, '"somethingElse":"123"'))
45
+ })
40
46
  })
41
- })
42
47
 
43
- describe('matching.matchingmode.regexp', function () {
44
- beforeEach(async function () {
45
- const myCaps = {
46
- [Capabilities.PROJECTNAME]: 'matching.matchingmode',
47
- [Capabilities.CONTAINERMODE]: echoConnector,
48
- [Capabilities.SCRIPTING_MATCHING_MODE]: 'regexp'
49
- }
50
- const driver = new BotDriver(myCaps)
51
- this.compiler = driver.BuildCompiler()
52
- this.container = await driver.Build()
53
- })
54
- afterEach(async function () {
55
- this.container && await this.container.Clean()
56
- })
48
+ describe('regexp', function () {
49
+ beforeEach(async function () {
50
+ const myCaps = {
51
+ [Capabilities.PROJECTNAME]: 'matching.matchingmode',
52
+ [Capabilities.CONTAINERMODE]: echoConnector,
53
+ [Capabilities.SCRIPTING_MATCHING_MODE]: 'regexp'
54
+ }
55
+ const driver = new BotDriver(myCaps)
56
+ this.compiler = driver.BuildCompiler()
57
+ this.container = await driver.Build()
58
+ })
59
+ afterEach(async function () {
60
+ this.container && await this.container.Clean()
61
+ })
57
62
 
58
- it('should check matching with regex', async function () {
59
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'regex.convo.txt')
60
- await this.compiler.convos[0].Run(this.container)
63
+ it('should check matching with regex', async function () {
64
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'regex.convo.txt')
65
+ await this.compiler.convos[0].Run(this.container)
66
+ })
67
+ it('should match case sensitive response', async function () {
68
+ assert.isTrue(this.compiler.Match('This is a long text', 'This .*'))
69
+ })
70
+ it('should not match uppercase response', async function () {
71
+ assert.isFalse(this.compiler.Match('THIS is a long text', 'This .*'))
72
+ })
61
73
  })
62
- it('should match case sensitive response', async function () {
63
- assert.isTrue(this.compiler.Match('This is a long text', 'This .*'))
64
- })
65
- it('should not match uppercase response', async function () {
66
- assert.isFalse(this.compiler.Match('THIS is a long text', 'This .*'))
67
- })
68
- })
69
74
 
70
- describe('matching.matchingmode.regexpIgnoreCase', function () {
71
- beforeEach(async function () {
72
- const myCaps = {
73
- [Capabilities.PROJECTNAME]: 'matching.matchingmode',
74
- [Capabilities.CONTAINERMODE]: echoConnector,
75
- [Capabilities.SCRIPTING_MATCHING_MODE]: 'regexpIgnoreCase'
76
- }
77
- const driver = new BotDriver(myCaps)
78
- this.compiler = driver.BuildCompiler()
79
- this.container = await driver.Build()
80
- })
81
- afterEach(async function () {
82
- this.container && await this.container.Clean()
83
- })
75
+ describe('regexpIgnoreCase', function () {
76
+ beforeEach(async function () {
77
+ const myCaps = {
78
+ [Capabilities.PROJECTNAME]: 'matching.matchingmode',
79
+ [Capabilities.CONTAINERMODE]: echoConnector,
80
+ [Capabilities.SCRIPTING_MATCHING_MODE]: 'regexpIgnoreCase'
81
+ }
82
+ const driver = new BotDriver(myCaps)
83
+ this.compiler = driver.BuildCompiler()
84
+ this.container = await driver.Build()
85
+ })
86
+ afterEach(async function () {
87
+ this.container && await this.container.Clean()
88
+ })
84
89
 
85
- it('should check matching with regex', async function () {
86
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'regex.convo.txt')
87
- await this.compiler.convos[0].Run(this.container)
88
- })
89
- it('should match case sensitive response', async function () {
90
- assert.isTrue(this.compiler.Match('This is a long text', 'This .*'))
91
- })
92
- it('should match uppercase response', async function () {
93
- assert.isTrue(this.compiler.Match('THIS is a long text', 'This .*'))
90
+ it('should check matching with regex', async function () {
91
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'regex.convo.txt')
92
+ await this.compiler.convos[0].Run(this.container)
93
+ })
94
+ it('should match case sensitive response', async function () {
95
+ assert.isTrue(this.compiler.Match('This is a long text', 'This .*'))
96
+ })
97
+ it('should match uppercase response', async function () {
98
+ assert.isTrue(this.compiler.Match('THIS is a long text', 'This .*'))
99
+ })
100
+ it('should not match if pattern is not matching', async function () {
101
+ assert.isFalse(this.compiler.Match('This is a long text', 'notthere .*'))
102
+ })
94
103
  })
95
- it('should not match if pattern is not matching', async function () {
96
- assert.isFalse(this.compiler.Match('This is a long text', 'notthere .*'))
97
- })
98
- })
99
104
 
100
- describe('matching.matchingmode.include', function () {
101
- beforeEach(async function () {
102
- const myCaps = {
103
- [Capabilities.PROJECTNAME]: 'matching.matchingmode',
104
- [Capabilities.CONTAINERMODE]: echoConnector,
105
- [Capabilities.SCRIPTING_MATCHING_MODE]: 'include'
106
- }
107
- const driver = new BotDriver(myCaps)
108
- this.compiler = driver.BuildCompiler()
109
- this.container = await driver.Build()
110
- })
111
- afterEach(async function () {
112
- this.container && await this.container.Clean()
113
- })
105
+ describe('include', function () {
106
+ beforeEach(async function () {
107
+ const myCaps = {
108
+ [Capabilities.PROJECTNAME]: 'matching.matchingmode',
109
+ [Capabilities.CONTAINERMODE]: echoConnector,
110
+ [Capabilities.SCRIPTING_MATCHING_MODE]: 'include'
111
+ }
112
+ const driver = new BotDriver(myCaps)
113
+ this.compiler = driver.BuildCompiler()
114
+ this.container = await driver.Build()
115
+ })
116
+ afterEach(async function () {
117
+ this.container && await this.container.Clean()
118
+ })
114
119
 
115
- it('should match case sensitive response', async function () {
116
- assert.isTrue(this.compiler.Match('This is a long text', 'is a'))
120
+ it('should match case sensitive response', async function () {
121
+ assert.isTrue(this.compiler.Match('This is a long text', 'is a'))
122
+ })
123
+ it('should not match uppercase response', async function () {
124
+ assert.isFalse(this.compiler.Match('This is a long text', 'IS A'))
125
+ })
126
+ it('should not match if pattern is not matching', async function () {
127
+ assert.isFalse(this.compiler.Match('This is a long text', 'notthere'))
128
+ })
117
129
  })
118
- it('should not match uppercase response', async function () {
119
- assert.isFalse(this.compiler.Match('This is a long text', 'IS A'))
120
- })
121
- it('should not match if pattern is not matching', async function () {
122
- assert.isFalse(this.compiler.Match('This is a long text', 'notthere'))
123
- })
124
- })
125
130
 
126
- describe('matching.matchingmode.wildcard', function () {
127
- beforeEach(async function () {
128
- const myCaps = {
129
- [Capabilities.PROJECTNAME]: 'matching.matchingmode',
130
- [Capabilities.CONTAINERMODE]: echoConnector,
131
- [Capabilities.SCRIPTING_MATCHING_MODE]: 'wildcard'
132
- }
133
- const driver = new BotDriver(myCaps)
134
- this.compiler = driver.BuildCompiler()
135
- this.container = await driver.Build()
136
- })
137
- afterEach(async function () {
138
- this.container && await this.container.Clean()
139
- })
131
+ describe('wildcard', function () {
132
+ beforeEach(async function () {
133
+ const myCaps = {
134
+ [Capabilities.PROJECTNAME]: 'matching.matchingmode',
135
+ [Capabilities.CONTAINERMODE]: echoConnector,
136
+ [Capabilities.SCRIPTING_MATCHING_MODE]: 'wildcard'
137
+ }
138
+ const driver = new BotDriver(myCaps)
139
+ this.compiler = driver.BuildCompiler()
140
+ this.container = await driver.Build()
141
+ })
142
+ afterEach(async function () {
143
+ this.container && await this.container.Clean()
144
+ })
140
145
 
141
- it('should match response with substring', async function () {
142
- assert.isTrue(this.compiler.Match('Interesting...', 'Interesting'))
143
- })
144
- it('should match long response with wildcard', async function () {
145
- assert.isTrue(this.compiler.Match('this is a long text', 'this is a * text'))
146
- })
147
- it('should match very long response with wildcard', async function () {
148
- assert.isTrue(this.compiler.Match('this is a long text this is a long text this is a long text this is a long text', 'this is a * text this is a * text this is a * text'))
149
- })
150
- it('should not match long uppcercase response with wildcard', async function () {
151
- assert.isFalse(this.compiler.Match('THIS IS A LONG TEXT', 'this is a * text'))
152
- })
153
- it('should match very long response with very long wildcard', async function () {
154
- assert.isTrue(this.compiler.Match('begin this is a long text this is a long text this is a long text this is a long text end', 'begin * end'))
155
- })
156
- it('should not allow more than 10 wildcards in a string', async function () {
157
- try {
158
- this.compiler.Match('some text', 'begin * * * * * * * * * * * end')
159
- assert.fail('should have failed')
160
- } catch (err) {
161
- assert.equal(err.message, 'Maximum number of 10 wildcards supported.')
162
- }
146
+ it('should match response with substring', async function () {
147
+ assert.isTrue(this.compiler.Match('Interesting...', 'Interesting'))
148
+ })
149
+ it('should match long response with wildcard', async function () {
150
+ assert.isTrue(this.compiler.Match('this is a long text', 'this is a * text'))
151
+ })
152
+ it('should match very long response with wildcard', async function () {
153
+ assert.isTrue(this.compiler.Match('this is a long text this is a long text this is a long text this is a long text', 'this is a * text this is a * text this is a * text'))
154
+ })
155
+ it('should not match long uppcercase response with wildcard', async function () {
156
+ assert.isFalse(this.compiler.Match('THIS IS A LONG TEXT', 'this is a * text'))
157
+ })
158
+ it('should match very long response with very long wildcard', async function () {
159
+ assert.isTrue(this.compiler.Match('begin this is a long text this is a long text this is a long text this is a long text end', 'begin * end'))
160
+ })
161
+ it('should not allow more than 10 wildcards in a string', async function () {
162
+ try {
163
+ this.compiler.Match('some text', 'begin * * * * * * * * * * * end')
164
+ assert.fail('should have failed')
165
+ } catch (err) {
166
+ assert.equal(err.message, 'Maximum number of 10 wildcards supported.')
167
+ }
168
+ })
169
+ it('should not match if pattern is not matching', async function () {
170
+ assert.isFalse(this.compiler.Match('This is a long text', '*notthere*'))
171
+ })
163
172
  })
164
- it('should not match if pattern is not matching', async function () {
165
- assert.isFalse(this.compiler.Match('This is a long text', '*notthere*'))
166
- })
167
- })
168
173
 
169
- describe('matching.matchingmode.wildcardIgnoreCase', function () {
170
- beforeEach(async function () {
171
- const myCaps = {
172
- [Capabilities.PROJECTNAME]: 'matching.matchingmode',
173
- [Capabilities.CONTAINERMODE]: echoConnector,
174
- [Capabilities.SCRIPTING_MATCHING_MODE]: 'wildcardIgnoreCase'
175
- }
176
- const driver = new BotDriver(myCaps)
177
- this.compiler = driver.BuildCompiler()
178
- this.container = await driver.Build()
179
- })
180
- afterEach(async function () {
181
- this.container && await this.container.Clean()
182
- })
174
+ describe('wildcardIgnoreCase', function () {
175
+ beforeEach(async function () {
176
+ const myCaps = {
177
+ [Capabilities.PROJECTNAME]: 'matching.matchingmode',
178
+ [Capabilities.CONTAINERMODE]: echoConnector,
179
+ [Capabilities.SCRIPTING_MATCHING_MODE]: 'wildcardIgnoreCase'
180
+ }
181
+ const driver = new BotDriver(myCaps)
182
+ this.compiler = driver.BuildCompiler()
183
+ this.container = await driver.Build()
184
+ })
185
+ afterEach(async function () {
186
+ this.container && await this.container.Clean()
187
+ })
183
188
 
184
- it('should match response with substring', async function () {
185
- assert.isTrue(this.compiler.Match('You said: So.....', 'so...'))
186
- })
187
- it('should match long response with wildcard', async function () {
188
- assert.isTrue(this.compiler.Match('this is a long text', 'this is a * text'))
189
- })
190
- it('should match long uppcercase response with wildcard', async function () {
191
- assert.isTrue(this.compiler.Match('THIS IS A LONG TEXT', 'this is a * text'))
192
- })
193
- it('should not match if pattern is not matching', async function () {
194
- assert.isFalse(this.compiler.Match('This is a long text', '*notthere*'))
195
- })
196
- it('should match response with utterances list', async function () {
197
- this.compiler.scriptingEvents.assertBotResponse('So.....', [
198
- 'lol',
199
- 'okay',
200
- 'so...',
201
- 'go on',
202
- 'umm',
203
- 'interesting',
204
- 'really?'
205
- ], 'test')
189
+ it('should match response with substring', async function () {
190
+ assert.isTrue(this.compiler.Match('You said: So.....', 'so...'))
191
+ })
192
+ it('should match long response with wildcard', async function () {
193
+ assert.isTrue(this.compiler.Match('this is a long text', 'this is a * text'))
194
+ })
195
+ it('should match long uppcercase response with wildcard', async function () {
196
+ assert.isTrue(this.compiler.Match('THIS IS A LONG TEXT', 'this is a * text'))
197
+ })
198
+ it('should not match if pattern is not matching', async function () {
199
+ assert.isFalse(this.compiler.Match('This is a long text', '*notthere*'))
200
+ })
201
+ it('should match response with utterances list', async function () {
202
+ this.compiler.scriptingEvents.assertBotResponse('So.....', [
203
+ 'lol',
204
+ 'okay',
205
+ 'so...',
206
+ 'go on',
207
+ 'umm',
208
+ 'interesting',
209
+ 'really?'
210
+ ], 'test')
211
+ })
206
212
  })
207
- })
208
213
 
209
- describe('matching.matchingmode.wildcardExact', function () {
210
- beforeEach(async function () {
211
- const myCaps = {
212
- [Capabilities.PROJECTNAME]: 'matching.matchingmode',
213
- [Capabilities.CONTAINERMODE]: echoConnector,
214
- [Capabilities.SCRIPTING_MATCHING_MODE]: 'wildcardExact'
215
- }
216
- const driver = new BotDriver(myCaps)
217
- this.compiler = driver.BuildCompiler()
218
- this.container = await driver.Build()
219
- })
220
- afterEach(async function () {
221
- this.container && await this.container.Clean()
222
- })
214
+ describe('wildcardExact', function () {
215
+ beforeEach(async function () {
216
+ const myCaps = {
217
+ [Capabilities.PROJECTNAME]: 'matching.matchingmode',
218
+ [Capabilities.CONTAINERMODE]: echoConnector,
219
+ [Capabilities.SCRIPTING_MATCHING_MODE]: 'wildcardExact'
220
+ }
221
+ const driver = new BotDriver(myCaps)
222
+ this.compiler = driver.BuildCompiler()
223
+ this.container = await driver.Build()
224
+ })
225
+ afterEach(async function () {
226
+ this.container && await this.container.Clean()
227
+ })
223
228
 
224
- it('should not match response with substring', async function () {
225
- assert.isFalse(this.compiler.Match('Interesting...', 'Interesting'))
226
- })
227
- it('should match long response with wildcard', async function () {
228
- assert.isTrue(this.compiler.Match('this is a long text', 'this is a * text'))
229
- })
230
- it('should match very long response with wildcard', async function () {
231
- assert.isTrue(this.compiler.Match('this is a long text this is a long text this is a long text this is a long text', 'this is a * text this is a * text this is a * text this is a * text'))
232
- })
233
- it('should not match long uppcercase response with wildcard', async function () {
234
- assert.isFalse(this.compiler.Match('THIS IS A LONG TEXT', 'this is a * text'))
235
- })
236
- it('should match very long response with very long wildcard', async function () {
237
- assert.isTrue(this.compiler.Match('begin this is a long text this is a long text this is a long text this is a long text end', 'begin * end'))
229
+ it('should not match response with substring', async function () {
230
+ assert.isFalse(this.compiler.Match('Interesting...', 'Interesting'))
231
+ })
232
+ it('should match long response with wildcard', async function () {
233
+ assert.isTrue(this.compiler.Match('this is a long text', 'this is a * text'))
234
+ })
235
+ it('should match very long response with wildcard', async function () {
236
+ assert.isTrue(this.compiler.Match('this is a long text this is a long text this is a long text this is a long text', 'this is a * text this is a * text this is a * text this is a * text'))
237
+ })
238
+ it('should not match long uppcercase response with wildcard', async function () {
239
+ assert.isFalse(this.compiler.Match('THIS IS A LONG TEXT', 'this is a * text'))
240
+ })
241
+ it('should match very long response with very long wildcard', async function () {
242
+ assert.isTrue(this.compiler.Match('begin this is a long text this is a long text this is a long text this is a long text end', 'begin * end'))
243
+ })
244
+ it('should not allow more than 10 wildcards in a string', async function () {
245
+ try {
246
+ this.compiler.Match('some text', 'begin * * * * * * * * * * * end')
247
+ assert.fail('should have failed')
248
+ } catch (err) {
249
+ assert.equal(err.message, 'Maximum number of 10 wildcards supported.')
250
+ }
251
+ })
252
+ it('should not match if pattern is not matching', async function () {
253
+ assert.isFalse(this.compiler.Match('This is a long text', '*notthere*'))
254
+ })
238
255
  })
239
- it('should not allow more than 10 wildcards in a string', async function () {
240
- try {
241
- this.compiler.Match('some text', 'begin * * * * * * * * * * * end')
242
- assert.fail('should have failed')
243
- } catch (err) {
244
- assert.equal(err.message, 'Maximum number of 10 wildcards supported.')
245
- }
246
- })
247
- it('should not match if pattern is not matching', async function () {
248
- assert.isFalse(this.compiler.Match('This is a long text', '*notthere*'))
249
- })
250
- })
251
256
 
252
- describe('matching.matchingmode.equals', function () {
253
- beforeEach(async function () {
254
- const myCaps = {
255
- [Capabilities.PROJECTNAME]: 'matching.matchingmode',
256
- [Capabilities.CONTAINERMODE]: echoConnector,
257
- [Capabilities.SCRIPTING_MATCHING_MODE]: 'equals'
258
- }
259
- const driver = new BotDriver(myCaps)
260
- this.compiler = driver.BuildCompiler()
261
- this.container = await driver.Build()
262
- })
263
- afterEach(async function () {
264
- this.container && await this.container.Clean()
265
- })
257
+ describe('equals', function () {
258
+ beforeEach(async function () {
259
+ const myCaps = {
260
+ [Capabilities.PROJECTNAME]: 'matching.matchingmode',
261
+ [Capabilities.CONTAINERMODE]: echoConnector,
262
+ [Capabilities.SCRIPTING_MATCHING_MODE]: 'equals'
263
+ }
264
+ const driver = new BotDriver(myCaps)
265
+ this.compiler = driver.BuildCompiler()
266
+ this.container = await driver.Build()
267
+ })
268
+ afterEach(async function () {
269
+ this.container && await this.container.Clean()
270
+ })
266
271
 
267
- it('should match case sensitive response', async function () {
268
- assert.isTrue(this.compiler.Match('This is a long text', 'This is a long text'))
269
- })
270
- it('should not match uppercase response', async function () {
271
- assert.isFalse(this.compiler.Match('This is a long text', 'THIS is a long text'))
272
- })
273
- it('should not match for partial match', async function () {
274
- assert.isFalse(this.compiler.Match('This is a long text', 'long'))
272
+ it('should match case sensitive response', async function () {
273
+ assert.isTrue(this.compiler.Match('This is a long text', 'This is a long text'))
274
+ })
275
+ it('should not match uppercase response', async function () {
276
+ assert.isFalse(this.compiler.Match('This is a long text', 'THIS is a long text'))
277
+ })
278
+ it('should not match for partial match', async function () {
279
+ assert.isFalse(this.compiler.Match('This is a long text', 'long'))
280
+ })
275
281
  })
276
- })
277
282
 
278
- describe('matching.matchingmode.equalsIgnorcase', function () {
279
- beforeEach(async function () {
280
- const myCaps = {
281
- [Capabilities.PROJECTNAME]: 'matching.matchingmode',
282
- [Capabilities.CONTAINERMODE]: echoConnector,
283
- [Capabilities.SCRIPTING_MATCHING_MODE]: 'equalsIgnoreCase'
284
- }
285
- const driver = new BotDriver(myCaps)
286
- this.compiler = driver.BuildCompiler()
287
- this.container = await driver.Build()
288
- })
289
- afterEach(async function () {
290
- this.container && await this.container.Clean()
291
- })
283
+ describe('equalsIgnorcase', function () {
284
+ beforeEach(async function () {
285
+ const myCaps = {
286
+ [Capabilities.PROJECTNAME]: 'matching.matchingmode',
287
+ [Capabilities.CONTAINERMODE]: echoConnector,
288
+ [Capabilities.SCRIPTING_MATCHING_MODE]: 'equalsIgnoreCase'
289
+ }
290
+ const driver = new BotDriver(myCaps)
291
+ this.compiler = driver.BuildCompiler()
292
+ this.container = await driver.Build()
293
+ })
294
+ afterEach(async function () {
295
+ this.container && await this.container.Clean()
296
+ })
292
297
 
293
- it('should match case sensitive response', async function () {
294
- assert.isTrue(this.compiler.Match('This is a long text', 'This is a long text'))
298
+ it('should match case sensitive response', async function () {
299
+ assert.isTrue(this.compiler.Match('This is a long text', 'This is a long text'))
300
+ })
301
+ it('should match uppercase response', async function () {
302
+ assert.isTrue(this.compiler.Match('This is a long text', 'THIS is a long text'))
303
+ })
304
+ it('should not match for partial match', async function () {
305
+ assert.isFalse(this.compiler.Match('This is a long text', 'long'))
306
+ })
295
307
  })
296
- it('should match uppercase response', async function () {
297
- assert.isTrue(this.compiler.Match('This is a long text', 'THIS is a long text'))
308
+
309
+ describe('wer.lowthreshold', function () {
310
+ beforeEach(async function () {
311
+ const myCaps = {
312
+ [Capabilities.PROJECTNAME]: 'matching.matchingmode',
313
+ [Capabilities.CONTAINERMODE]: echoConnector,
314
+ [Capabilities.SCRIPTING_MATCHING_MODE]: 'wer',
315
+ [Capabilities.SCRIPTING_MATCHING_MODE_ARGS]: [0.1]
316
+ }
317
+ const driver = new BotDriver(myCaps)
318
+ this.compiler = driver.BuildCompiler()
319
+ this.container = await driver.Build()
320
+ })
321
+ afterEach(async function () {
322
+ this.container && await this.container.Clean()
323
+ })
324
+
325
+ it('should not match because of low threshold', async function () {
326
+ assert.isFalse(this.compiler.Match('test 123', 'tast 123'))
327
+ })
298
328
  })
299
- it('should not match for partial match', async function () {
300
- assert.isFalse(this.compiler.Match('This is a long text', 'long'))
329
+
330
+ describe('wer.highthreshold', function () {
331
+ beforeEach(async function () {
332
+ const myCaps = {
333
+ [Capabilities.PROJECTNAME]: 'matching.matchingmode',
334
+ [Capabilities.CONTAINERMODE]: echoConnector,
335
+ [Capabilities.SCRIPTING_MATCHING_MODE]: 'wer',
336
+ [Capabilities.SCRIPTING_MATCHING_MODE_ARGS]: [0.6]
337
+ }
338
+ const driver = new BotDriver(myCaps)
339
+ this.compiler = driver.BuildCompiler()
340
+ this.container = await driver.Build()
341
+ })
342
+ afterEach(async function () {
343
+ this.container && await this.container.Clean()
344
+ })
345
+
346
+ it('should match because of high threshold', async function () {
347
+ assert.isTrue(this.compiler.Match('test 123', 'tast 123'))
348
+ })
301
349
  })
302
350
  })