diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4afd0fe --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# No IDE file +.idea +lambda/custom/node_modules/ +coverage \ No newline at end of file diff --git a/lambda/custom/index.js b/lambda/custom/index.js index 2ca2fa7..91f4f42 100644 --- a/lambda/custom/index.js +++ b/lambda/custom/index.js @@ -104,6 +104,11 @@ const YesIntent = { sessionAttributes.gameState = 'STARTED'; sessionAttributes.guessNumber = Math.floor(Math.random() * 101); + // For testing purposes, force a number to be picked if the UNIT_TEST environment variable is set + if (process.env.UNIT_TEST) { + sessionAttributes.guessNumber = 50; + } + return responseBuilder .speak('Great! Try saying a number to start the game.') .reprompt('Try saying a number.') diff --git a/lambda/custom/package-lock.json b/lambda/custom/package-lock.json new file mode 100644 index 0000000..c98d857 --- /dev/null +++ b/lambda/custom/package-lock.json @@ -0,0 +1,138 @@ +{ + "name": "skill-sample-nodejs-highlowgame", + "version": "2.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "ask-sdk": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/ask-sdk/-/ask-sdk-2.0.5.tgz", + "integrity": "sha512-SYNOFpuFAjz3Z5/7a9Lq8G1XzJ9zdDlYsb1ZUHvZO3Xr4tc/wAWH4kP3OK6IXV9kHJs3cLnJjmuMHKH8DVwfIw==", + "requires": { + "ask-sdk-core": "2.0.5", + "ask-sdk-dynamodb-persistence-adapter": "2.0.5", + "ask-sdk-model": "1.2.0" + } + }, + "ask-sdk-core": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/ask-sdk-core/-/ask-sdk-core-2.0.5.tgz", + "integrity": "sha512-XW95Wh+eMgOGBJKv15NvNip5QabOYu4nVw2qpZvb1PYZiw5ERVESiX26As+S/Iy63ZC7YbiI+o667z93xlUHKw==" + }, + "ask-sdk-dynamodb-persistence-adapter": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/ask-sdk-dynamodb-persistence-adapter/-/ask-sdk-dynamodb-persistence-adapter-2.0.5.tgz", + "integrity": "sha512-VJRHRTl6KNs9DJYdB5n4BArsvZgpDHpybKtRzEWrI69JJprfobJo6LCr2ghh+vTLQJJ8fb0jDp7quL5wOYO/rw==", + "requires": { + "aws-sdk": "2.241.1" + } + }, + "ask-sdk-model": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/ask-sdk-model/-/ask-sdk-model-1.2.0.tgz", + "integrity": "sha512-GD9WwIq8c5fparwZOQm2IxboDu5cs6JMsgFISQIVUNmCdnprxr5PgaQMA55JOGs94bwIEJ6gc8i1mVyfFX75Vw==" + }, + "aws-sdk": { + "version": "2.241.1", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.241.1.tgz", + "integrity": "sha1-rk4bp3LMFyhN8AwDtY3PkU1ccvk=", + "requires": { + "buffer": "4.9.1", + "events": "1.1.1", + "ieee754": "1.1.8", + "jmespath": "0.15.0", + "querystring": "0.2.0", + "sax": "1.2.1", + "url": "0.10.3", + "uuid": "3.1.0", + "xml2js": "0.4.17" + } + }, + "base64-js": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", + "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" + }, + "buffer": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "requires": { + "base64-js": "1.3.0", + "ieee754": "1.1.8", + "isarray": "1.0.0" + } + }, + "events": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", + "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=" + }, + "ieee754": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz", + "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "jmespath": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", + "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=" + }, + "lodash": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" + }, + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" + }, + "querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" + }, + "sax": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", + "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=" + }, + "url": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", + "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=", + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + } + }, + "uuid": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", + "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" + }, + "xml2js": { + "version": "0.4.17", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.17.tgz", + "integrity": "sha1-F76T6q4/O3eTWceVtBlwWogX6Gg=", + "requires": { + "sax": "1.2.1", + "xmlbuilder": "4.2.1" + } + }, + "xmlbuilder": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.2.1.tgz", + "integrity": "sha1-qlijBBoGb5DqoWwvU4n/GfP0YaU=", + "requires": { + "lodash": "4.17.10" + } + } + } +} diff --git a/test/unit/index.test.yml b/test/unit/index.test.yml new file mode 100644 index 0000000..fa7a2a8 --- /dev/null +++ b/test/unit/index.test.yml @@ -0,0 +1,125 @@ +#===================================================================================================================== +# ______ _ ____ ______ __ _ +# / __/ /__ (_) / / /_ __/__ ___ / /_(_)__ ___ _ +# _\ \/ '_// / / / / / / -_|_-