This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from stanzheng/master
Adding Tests -- WIP #1
- Loading branch information
Showing
5 changed files
with
98 additions
and
25 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
language: node_js | ||
sudo: false | ||
node_js: | ||
- "0.11" | ||
- "0.10" |
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
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,59 @@ | ||
var assert = require("assert"); | ||
var express = require("express"); | ||
var r = require("supertest"); | ||
var parseString = require('xml2js').parseString; | ||
var should = require('should'); | ||
/** | ||
* Test | ||
* | ||
* @param {Object} req - The request value. | ||
**/ | ||
process.env.PORT = 4000; | ||
var app = require("../app.js"); | ||
|
||
|
||
describe('General incoming request', function(){ | ||
|
||
it('responds with xml', function(done){ | ||
r(app) | ||
.post('/msg') | ||
.send({Body:"8004"}) | ||
.set('Accept', 'application/xml') | ||
.expect(200) | ||
.end(function(err, res){ | ||
if (err) throw err; | ||
done(); | ||
}); | ||
}); | ||
|
||
it('light rail stops are valid, testing 8004', function(done){ | ||
r(app) | ||
.post('/msg') | ||
.send({Body:"8004"}) | ||
.set('Accept', 'application/xml') | ||
.expect(200) | ||
.end(function(err, res){ | ||
if (err) throw err; | ||
should.not.exist(err); | ||
|
||
// cleans utf8 parsing for xml in form | ||
// see http://www.multiasking.com/blog/xml2js-sax-js-non-whitespace-before-first-tag/ | ||
var xml = res.text.replace("\ufeff", ""); | ||
parseString(xml, function (err, ouput) { | ||
var parse = ouput.Response.Message[0]; | ||
parse.should.startWith('Light rail '); | ||
//parse.should.have("Light rail"); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
// #TODO Tests for | ||
// Bounding Boxes | ||
// Asking for help | ||
// Checking for input a known address | ||
// Checking for input a unknown/invalid address | ||
// Check for known stop number | ||
// Check for unknown/invalid stop number |