File tree Expand file tree Collapse file tree 3 files changed +33
-2
lines changed Expand file tree Collapse file tree 3 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -151,4 +151,5 @@ export async function downloadScripts(url: string): Promise<string[]> {
151
151
*/
152
152
export {
153
153
clean ,
154
+ axios ,
154
155
} ;
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ describe('Plugin', () => {
75
75
req.variables.name = 'Bob';
76
76
req.variables.intent = 'ask name';
77
77
~~~
78
- ` )
78
+ ` ) ;
79
79
// .plugin('human name', async (req, ctx) => {
80
80
// req.variables.name = 'Bob';
81
81
// req.variables.intent = 'ask name';
@@ -109,7 +109,7 @@ describe('Plugin', () => {
109
109
req.variables.fired = true;
110
110
req.$flows.name = 'Bob';
111
111
~~~
112
- ` )
112
+ ` ) ;
113
113
// .plugin('human name', async (req, ctx) => {
114
114
// req.variables.fired = true;
115
115
// req.$flows.name = 'Bob';
Original file line number Diff line number Diff line change
1
+ import { BotScript , Request } from '../../src/engine' ;
2
+ import { assert } from 'chai' ;
3
+
4
+ describe ( 'Plugin: utils' , ( ) => {
5
+
6
+ describe ( 'axios' , ( ) => {
7
+ const botPlugin = new BotScript ( ) ;
8
+ botPlugin
9
+ . parse ( `
10
+ > query answer
11
+
12
+ + send question
13
+ - answer $answer
14
+
15
+ /plugin: query answer
16
+ ~~~js
17
+ const vResp = await utils.axios.get('http://httpbin.org/get?answer=42');
18
+ req.variables.answer = vResp.data.args.answer;
19
+ ~~~
20
+ ` ) ;
21
+
22
+ it ( 'should get answer from httpbin service' , async ( ) => {
23
+ let req = new Request ( 'send question' ) ;
24
+
25
+ req = await botPlugin . handleAsync ( req ) ;
26
+ assert . equal ( req . speechResponse , 'answer 42' , 'send request and get value back' ) ;
27
+ } ) ;
28
+
29
+ } ) ;
30
+ } ) ;
You can’t perform that action at this time.
0 commit comments