diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c11e52a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - "0.12" diff --git a/package.json b/package.json index a360f21..7b57b50 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "A sample Node.js app using Express 4", "main": "index.js", "scripts": { - "start": "node index.js" + "start": "node index.js", + "test": "./node_modules/.bin/mocha" }, "dependencies": { "cheerio": "^0.19.0", @@ -13,6 +14,12 @@ "request": "^2.57.0", "string": "^3.2.0" }, + "devDependencies": { + "chai": "^3.0.0", + "chai-as-promised": "^5.1.0", + "mocha": "^2.2.5", + "nock": "^2.5.0" + }, "engines": { "node": "0.12.2" }, diff --git a/test/gaugeSpec.js b/test/gaugeSpec.js new file mode 100644 index 0000000..eb15f82 --- /dev/null +++ b/test/gaugeSpec.js @@ -0,0 +1,21 @@ +var chai = require("chai"); +var chaiAsPromised = require("chai-as-promised"); +var nock = require("nock"); + +var should = chai.should(); +chai.use(chaiAsPromised); + +var gauge = require("../lib/gauge.js"); + + +describe("Gauge", function() { + describe("gauge()", function() { + it("should return gauge level", function() { + var gaugePage = nock('http://waterdata.usgs.gov') + .get('/usa/nwis/uv?07164500') + .replyWithFile(200, __dirname + '/replies/gauge3.html'); + + return gauge().should.eventually.equal(8.9); + }); + }); +}); diff --git a/test/replies/gauge3.html b/test/replies/gauge3.html new file mode 100644 index 0000000..6fcd893 --- /dev/null +++ b/test/replies/gauge3.html @@ -0,0 +1,1225 @@ + +
+Min (1991) | 25th percen- tile | Median | Mean | 75th percen- tile | Most Recent Instantaneous Value Jun 14 | Max (1995) |
+
---|---|---|---|---|---|---|
72 | 3810 | 9550 | 14700 | 17700 | 40000 | 111000 | +