forked from alexa-samples/skill-sample-nodejs-city-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
51 lines (42 loc) · 1.35 KB
/
test.js
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
// This is a Javascript test harness that simulates the execution of Lambda function code
// From the command prompt, type "node test.js"
var MyLambdaFunction = require('../src/index.js'); // assumes single Lambda function with exports.handler
// this is the Lambda request data, generated by the Alexa service. Replace with your actual Alexa request.
var event =
{
"session": {
"sessionId": "SessionId.f9e6dcbb-b7da-4b47-905c.etc.etc",
"application": {
"applicationId": "amzn1.echo-sdk-ams.app.1234"
},
"attributes": {},
"user": {
"userId": "amzn1.ask.account.VO3PVTGF563MOPBY.etc.etc"
},
"new": true
},
"request": {
"type": "LaunchRequest",
"requestId": "request5678",
"locale": "en-US"
},
"version": "1.0"
};
var context = {
'succeed': function (data) {
console.log(JSON.stringify(data, null,'\t') );
},
'fail': function (err) {
console.log('context.fail occurred');
console.log(JSON.stringify(err, null,'\t') );
}
};
function callback(error, data) {
if(error) {
console.log('error: ' + error);
} else {
console.log(data);
}
}
// call the function
MyLambdaFunction['handler'] (event, context, callback);