-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add general support for upcoming request types #313
Closed
Closed
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8f85ef2
Merge pull request #1 from alexa-js/master
matt-kruse 2e0eccf
Merge branch 'master' of https://github.com/alexa-js/alexa-app
matt-kruse cec5073
Add general support for upcoming request types
matt-kruse c90db65
Fix TypeScript type definition typo
lazerwalker e850e4c
Fix index.d.ts trailing whitespace
lazerwalker eb72047
Tests for PR #313
matt-kruse f52184d
Changelog
matt-kruse 6e864b6
Merge branch 'master' into future-features
matt-kruse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"version": "1.0", | ||
"session": { | ||
"new": true, | ||
"sessionId": "amzn1.echo-api.session.abeee1a7-aee0-41e6-8192-e6faaed9f5ef", | ||
"application": { | ||
"applicationId": "amzn1.echo-sdk-ams.app.000000-d0ed-0000-ad00-000000d00ebe" | ||
}, | ||
"attributes": {}, | ||
"user": { | ||
"userId": "amzn1.account.AM3B227HF3FAM1B261HK7FFM3A2" | ||
} | ||
}, | ||
"request": { | ||
"type": "GameEngine.InputHandlerEvent", | ||
"requestId": "amzn1.echo-api.request.9cdaa4db-f20e-4c58-8d01-c75322d6c423", | ||
"timestamp": "2015-05-13T12:34:56Z", | ||
"events": [ | ||
{ | ||
"name": "myEventName", | ||
"inputEvents": [ | ||
{ | ||
"gadgetId": "someGadgetId1", | ||
"timestamp": "2015-05-13T12:34:56Z", | ||
"action": "down", | ||
"color": "FF0000" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"context": { | ||
"System": { | ||
"user": { | ||
"userId": "amzn1.account.AM3B227HF3FAM1B261HK7FFM3A2" | ||
}, | ||
"application": { | ||
"applicationId": "amzn1.echo-sdk-ams.app.000000-d0ed-0000-ad00-000000d00ebe" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/*jshint expr: true*/ | ||
"use strict"; | ||
var chai = require("chai"); | ||
var chaiAsPromised = require("chai-as-promised"); | ||
var mockHelper = require("./helpers/mock_helper"); | ||
chai.use(chaiAsPromised); | ||
var expect = chai.expect; | ||
chai.config.includeStack = true; | ||
|
||
import * as Alexa from '..'; | ||
|
||
describe("Alexa", function() { | ||
describe("app", function() { | ||
var testApp = new Alexa.app("testApp"); | ||
|
||
beforeEach(function() { | ||
testApp = new Alexa.app("testApp"); | ||
}); | ||
|
||
describe("#request", function() { | ||
describe("response", function() { | ||
var mockRequest = mockHelper.load("intent_request_on.json"); | ||
|
||
context("with a request of type GameEngine.InputHandlerEvent", function() { | ||
context("with no type handler", function() { | ||
describe("outputSpeech", function() { | ||
it("responds with INVALID_REQUEST_TYPE message", function() { | ||
var subject = testApp.request(mockRequest).then(function(response) { | ||
return response.response.outputSpeech; | ||
}); | ||
|
||
return expect(subject).to.eventually.become({ | ||
ssml: "<speak>" + testApp.messages.INVALID_REQUEST_TYPE + "</speak>", | ||
type: "SSML" | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
context("with a matching type handler", function() { | ||
var expectedMessage="Valid Response"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another stuck |
||
testApp.on('GameEngine.InputHandlerEvent',function(req,res) { | ||
res.say(expectedMessage); | ||
}); | ||
describe("outputSpeech", function() { | ||
it("responds with expected message", function() { | ||
testApp.on('GameEngine.InputHandlerEvent',function(req, res) { | ||
res.say(expectedMessage); | ||
}); | ||
|
||
var subject = testApp.request(mockRequest).then(function(response) { | ||
return response.response.outputSpeech; | ||
}); | ||
|
||
return expect(subject).to.eventually.become({ | ||
ssml: "<speak>" + expectedMessage + "</speak>", | ||
type: "SSML" | ||
}); | ||
}); | ||
|
||
it("responds with expected message for promise", function() { | ||
testApp.on('GameEngine.InputHandlerEvent',function(req, res) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another missing space after |
||
return Promise.resolve().then(function() { | ||
res.say(expectedMessage); | ||
}); | ||
}); | ||
|
||
var subject = testApp.request(mockRequest).then(function(response) { | ||
return response.response.outputSpeech; | ||
}); | ||
|
||
return expect(subject).to.eventually.become({ | ||
ssml: "<speak>" + expectedMessage + "</speak>", | ||
type: "SSML" | ||
}); | ||
}); | ||
|
||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking, there should be some spaces around those
==
.