Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
adding test for light rail stop
Browse files Browse the repository at this point in the history
  • Loading branch information
stanley zheng committed Dec 18, 2014
1 parent d40c0ec commit 28ddce5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
"path": "^0.4.9",
"querystring": "^0.2.0",
"request": "^2.51.0",
"should": "^4.4.1",
"supertest": "^0.15.0",
"twilio": "^1.7.0",
"where": "^0.1.2"
"where": "^0.1.2",
"xml2js": "^0.4.4"
},
"devDependencies": {
"mocha": "^2.0.1"
Expand Down
32 changes: 25 additions & 7 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var assert = require("assert");
var express = require("express");
var r = require("supertest");

var parseString = require('xml2js').parseString;
var should = require('should');
/**
* Test
*
Expand All @@ -12,6 +13,7 @@ var app = require("../app.js");


describe('General incoming request', function(){

it('responds with xml', function(done){
r(app)
.post('/msg')
Expand All @@ -23,13 +25,29 @@ describe('General incoming request', function(){
done();
});
});
});


function clientError(e) {
return e.code >= 400 && e.code < 500;
}

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
Expand Down

0 comments on commit 28ddce5

Please sign in to comment.