Skip to content

Instantly share code, notes, and snippets.

@aadennis
Created October 1, 2017 16:34
Show Gist options
  • Save aadennis/f65d02453cbd2a3d168baa0075194d25 to your computer and use it in GitHub Desktop.
Save aadennis/f65d02453cbd2a3d168baa0075194d25 to your computer and use it in GitHub Desktop.
VsCodeJavaScriptSnippets.js
{
"Print to console": {
"prefix": "dw-testlambdajs-example",
"body": [
"'use strict';",
"// Package imports...",
"const LambdaTester = require('lambda-tester');",
"const expect = require('chai').expect;",
"",
"// Local helpers...",
"const testEvent = require('./testEventSet')",
"",
"// Handler under test...",
"const handlerUnderTest = require('../src/index').handler;",
"log",
"describe('lambda-tester sandbox', function () {",
" it('1. callback test: returns the expected Space Fact', function () {",
" var serviceRequest = testEvent.GetNewFactIntent_Event;",
" return LambdaTester(handlerUnderTest)",
" .event(serviceRequest)",
" .expectResult((serviceResponse, additional) => {",
" expect(serviceResponse).to.exist;",
" expect(serviceResponse.response.card.content)",
" .to.equal('A year on Mercury is just 88 days long.');",
" });",
" });",
"",
" it('2. callback test: returns the expected Help', function () {",
" var serviceRequest = testEvent.AMAZON_HelpIntent_Event;",
" return LambdaTester(handlerUnderTest)",
" .event(serviceRequest)",
" .expectResult((serviceResponse, additional) => {",
" expect(serviceResponse).to.exist;",
" expect(serviceResponse.response.outputSpeech.ssml)",
" .to.equal('<speak> You can say tell me a space fact, or, you can say exit... What can I help you with? </speak>');",
" });",
" });",
"});"
],
"description": "dw-testlambdajs-example"
},
"Skill Event Sample 1 ": {
"prefix": "dw-SkillEvent-example",
"body": [
"var GetNewFactIntent_Event =",
"{",
" \"session\": {",
" \"new\": false,",
" \"sessionId\": \"session123\",",
" \"attributes\": {},",
" \"user\": {",
" \"userId\": \"jonny123\"",
" },",
" \"application\": {",
" \"applicationId\": \"amzn1.ask.skill.456\"",
" }",
" },",
" \"version\": \"1.0\",",
" \"request\": {",
" \"locale\": \"en-US\",",
" \"timestamp\": \"2016-10-27T21:06:28Z\",",
" \"type\": \"IntentRequest\",",
" \"requestId\": \"req123\",",
" \"intent\": {",
" \"slots\": {},",
" \"name\": \"GetNewFactIntent\"",
" }",
" },",
" \"context\": {",
" \"AudioPlayer\": {",
" \"playerActivity\": \"IDLE\"",
" },",
" \"System\": {",
" \"device\": {",
" \"supportedInterfaces\": {",
" \"AudioPlayer\": {}",
" }",
" },",
" \"application\": {",
" \"applicationId\": \"amzn1.ask.skill.123\"",
" },",
" \"user\": {",
" \"userId\": \"jonny123\"",
" }",
" }",
" }",
"};",
"",
"var AMAZON_HelpIntent_Event =",
"{",
" \"session\": {",
" \"new\": true,",
" \"sessionId\": \"SessionId.678\",",
" \"application\": {",
" \"applicationId\": \"amzn1.ask.skill.444\"",
" },",
" \"attributes\": {},",
" \"user\": {",
" \"userId\": \"SomeUser\"",
" }",
" },",
" \"request\": {",
" \"type\": \"IntentRequest\",",
" \"requestId\": \"EdwRequestId.000\",",
" \"intent\": {",
" \"name\": \"AMAZON.HelpIntent\",",
" \"slots\": {}",
" },",
" \"locale\": \"en-US\",",
" \"timestamp\": \"2017-09-23T19:24:44Z\"",
" },",
" \"context\": {",
" \"AudioPlayer\": {",
" \"playerActivity\": \"IDLE\"",
" },",
" \"System\": {",
" \"application\": {",
" \"applicationId\": \"amzn1.ask.skill.776655\"",
" },",
" \"user\": {",
" \"userId\": \"SomeUser\"",
" },",
" \"device\": {",
" \"supportedInterfaces\": {}",
" }",
" }",
" },",
" \"version\": \"1.0\"",
" };",
"",
"",
"module.exports.GetNewFactIntent_Event = GetNewFactIntent_Event;",
"module.exports.AMAZON_HelpIntent_Event = AMAZON_HelpIntent_Event;",
""
],
"description": "dw-SkillEvent-example"
},
"dw-AlexaPackageJsonExample1": {
"prefix": "dw-AlexaPackageJsonExample2",
"body": [
"{",
" \"name\": \"mahhello\",",
" \"version\": \"1.0.0\",",
" \"description\": \"More a dump of notes...\",",
" \"main\": \"index.js\",",
" \"dependencies\": {",
" \"alexa-sdk\": \"^1.0.14\"",
" },",
" \"devDependencies\": {",
" \"alexa-sdk\": \"^1.0.14\"",
" },",
" \"author\": \"Dennis Wells\",",
" \"license\": \"ISC\"",
"}"
],
"description": "dw-AlexaPackageJsonExample3"
},
"dw-AlexaPackageJsonTestProjectExample": {
"prefix": "dw-AlexaPackageJsonTestProjectExample",
"body": [
"{",
" \"name\": \"test\",",
" \"version\": \"1.0.0\",",
" \"description\": \"\",",
" \"main\": \"index.spec.js\",",
" \"scripts\": {",
" \"test\": \"mocha\"",
" },",
" \"author\": \"\",",
" \"license\": \"ISC\",",
" \"dependencies\": {",
" \"chai\": \"a412\",",
" \"lambda-tester\": \"a3.1.0\"",
"}"
],
"description": "dw-AlexaPackageJsonTestProjectExample"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment