Skip to content

Commit

Permalink
Fixed the endpoint message to use app.name to match the endpoint route (
Browse files Browse the repository at this point in the history
  • Loading branch information
zqylur authored and dblock committed Feb 20, 2017
1 parent 2be0f02 commit 94dd0a7
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* [#71](https://github.com/alexa-js/alexa-app-server/pull/71), [#68](https://github.com/alexa-js/alexa-app-server/issues/68): Fixed log output containing multiple slashes - [@tejashah88](https://github.com/tejashah88).
* [#72](https://github.com/alexa-js/alexa-app-server/pull/72): Use `path.join` for constructing relative paths - [@dblock](https://github.com/dblock).
* [#74](https://github.com/alexa-js/alexa-app-server/pull/74): Added locale selector to test page - [@siedi](https://github.com/siedi).
* [#76](https://github.com/alexa-js/alexa-app-server/pull/76): Changed endpoint message to use app name to match route - [@zweiler](https://github.com/zweiler).
* Your contribution here.

### 3.0.0 (February 6, 2017)
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ var appServer = function(config) {
postRequest: self.config.postRequest
});

var endpoint = path.posix.join(normalizedRoot, pkg.name);
var endpoint = path.posix.join(normalizedRoot, app.name);
self.log(" loaded app [" + pkg.name + "] at endpoint: " + endpoint);
});

Expand Down
11 changes: 11 additions & 0 deletions invalid_examples/apps/bad_app_name_mismatch/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var alexa = require('alexa-app');

// Allow this module to be reloaded by hotswap when changed
module.change_code = 1;

// Define an alexa-app
var app = new alexa.app('bad_app_name_mismatch');
app.launch(function(req,res) {
res.say("This app should message the app name endpoint, not the package.json name");
});
module.exports = app;
14 changes: 14 additions & 0 deletions invalid_examples/apps/bad_app_name_mismatch/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "bad_app_name-mismatch",
"version": "1.0.0",
"description": "A sample Alexa app",
"main": "index.js",
"author": "Matt Kruse <github@mattkruse.com> (http://mattkruse.com/)",
"license": "ISC",
"alexa": {
"applicationId":"amzn1.echo-sdk-ams.app.999999-d0ed-9999-ad00-999999d00ebe"
},
"dependencies": {
"alexa-app": "^2.1.0"
}
}
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
"lodash.defaults": "^4.2.0"
},
"devDependencies": {
"mocha": "^3.2.0",
"chai": "^3.5.0",
"supertest": "^3.0.0",
"istanbul": "0.4.5",
"coveralls": "^2.11.15",
"danger": "0.11.4",
"istanbul": "0.4.5",
"mocha": "^3.2.0",
"sinon": "^1.17.7",
"sinon-chai": "^2.8.0",
"supertest": "^3.0.0",
"tcp-port-used": "0.1.2"
}
}
16 changes: 16 additions & 0 deletions test/test-examples-server-app-loading-fail-checks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/*jshint expr: true*/
"use strict";
var chai = require("chai");
var sinon = require("sinon");
var sinonChai = require("sinon-chai");
chai.use(sinonChai);
var expect = chai.expect;
chai.config.includeStack = true;
var request = require("supertest");
Expand All @@ -25,4 +28,17 @@ describe("Alexa App Server with invalid examples", function() {
expect(response.text).to.contain("alexa-app-server is running");
});
});

it("loads apps with the app name in the endpoint message", function() {
sinon.spy(console, 'log');
testServer = alexaAppServer.start({
port: 3000,
server_root: 'invalid_examples'
});

var badAppNameMismatch = ' loaded app [bad_app_name-mismatch] at endpoint: /alexa/bad_app_name_mismatch';
expect(console.log).to.have.been.calledWithExactly(badAppNameMismatch);

console.log.restore();
});
});

0 comments on commit 94dd0a7

Please sign in to comment.