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 @@ + + +USGS Current Conditions for USGS 07164500 Arkansas River at Tulsa, OK + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ + +
+
+
USGS - science for a changing world +
+ +
+
+ + + + + +
+ +
+ + + + + + + + + + + + +

+ + + + + + + + + + + +
+
+ + Click to hideNews Bulletins +
+
+ + +
+
+ + + +
+ + + + + + + +
+ + +

USGS 07164500 Arkansas River at Tulsa, OK

+
+ +
+ +

PROVISIONAL DATA SUBJECT TO REVISION

+ + + + + + + +
+
+ + + + + + + + + + +
+
+
+ + + + +
+
+ + Click to hidestation-specific text +
+
+Station operated in cooperation with +the City of Tulsa and the Corps of Engineers.
+ +
+
+ + + This station managed by the Tulsa field office.

+ + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Available Parameters Available Period
All 4 Available Parameters for this site
  
00065 Gage height2007-10-01 2015-06-14
00060 Discharge2007-10-11 2015-06-14
00010 Temperature, water2007-11-21 2015-06-14
00300 Dissolved oxygen2011-01-05 2015-06-14
+
+ +

+ Graph
+ Graph w/ stats
+ Graph w/o stats
+ Graph w/ (up to 3) parms
+ Table
+ Tab-separated
+
+ +
+
+ + + +
+
+ Days  (7)
+  

  -- or --
+ Begin date
+  

+ End date
+  

+
+ +
+ +
+ +
+ +
+ + + + +Summary of all available data for this site +
+ +Instantaneous-data availability statement + +
+ +
+ +
+ +
+
+
Gage height, feet
+
+
+ +Most recent instantaneous value: 8.90   06-14-2015  08:30 CDT + + + +
+ +
+
+ Graph of +
+ +
+
+
+

Add up to 2 more sites and replot for "Gage height, feet"

+
+ ? +
 Add site numbers +
+ Note +
+
+ + + + +
+ +
+
+
+
+
+ + Create presentation-quality + / stand-alone graph.   Subscribe to WaterAlert       +
+ +
+
+ Share this graph + | + + + + +

+ + +
+ + +
+ +
+
+ +
+ +
+ +
+
+
Discharge, cubic feet per second
+
+
+ +Most recent instantaneous value: 40,000   06-14-2015  08:30 CDT + + + +
+ +
+
+ Graph of +
+ +
+
+
+

Add up to 2 more sites and replot for "Discharge, cubic feet per second"

+
+ ? +
 Add site numbers +
+ Note +
+
+ + + + +
+ +
+
+
+
+
+ + Create presentation-quality + / stand-alone graph.   Subscribe to WaterAlert       +
+ +
+
+ Share this graph + | + + + + +

+ + +
+ + +
+ + + + + + + + + + + + + +
Daily discharge, cubic feet per second -- statistics for Jun 14 based on 50 years of record more
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
+ +
+
+ +
+ +
+ +
+
+
Temperature, water, degrees Celsius
+
+
+ +Most recent instantaneous value: 23.2   06-14-2015  08:30 CDT + + + +
+ +
+
+ Graph of +
+ +
+
+
+

Add up to 2 more sites and replot for "Temperature, water, degrees Celsius"

+
+ ? +
 Add site numbers +
+ Note +
+
+ + + + +
+ +
+
+
+
+
+ + Create presentation-quality + / stand-alone graph.   Subscribe to WaterAlert       +
+ +
+
+ Share this graph + | + + + + +

+ + +
+ + +
+ +
+
+ +
+ +
+ +
+
+
Dissolved oxygen, water, unfiltered, milligrams per liter
+
+
+ +Most recent instantaneous value: 8.6   06-14-2015  08:30 CDT + + + +
+ +
+
+ Graph of +
+ +
+
+
+

Add up to 2 more sites and replot for "Dissolved oxygen, water, unfiltered, milligrams per liter"

+
+ ? +
 Add site numbers +
+ Note +
+
+ + + + +
+ +
+
+
+
+
+ + Create presentation-quality + / stand-alone graph.   Subscribe to WaterAlert       +
+ +
+
+ Share this graph + | + + + + +

+ + +
+ + +
+ +
+
+ +
+ + + + + +
\ No newline at end of file