Browse files

added city and zip methods

  • Loading branch information...
1 parent 8eb725a commit db33793ace43eb95479168aea33bdcb8a008c545 @jgallen23 committed Apr 2, 2012
Showing with 29 additions and 1 deletion.
  1. +1 −1 Makefile
  2. +9 −0 lib/placefinder.js
  3. +19 −0 {tests → test}/placefinder.test.js
View
2 Makefile
@@ -1,4 +1,4 @@
test:
- ./node_modules/.bin/nodeunit test/node.js
+ ./node_modules/.bin/nodeunit test/placefinder.test.js
.PHONY: test
View
9 lib/placefinder.js
@@ -27,4 +27,13 @@ PlaceFinder.prototype.placeOfInterest = function(name, callback) {
PlaceFinder.prototype.woeid = function(woeid, callback) {
this._makeRequest({ woeid: woeid }, callback);
};
+
+PlaceFinder.prototype.city = function(city, callback) {
+ this._makeRequest({ city: city }, callback);
+};
+
+PlaceFinder.prototype.zip = function(zip, callback) {
+ this._makeRequest({ postal: zip }, callback);
+};
+
module.exports = PlaceFinder;
View
19 tests/placefinder.test.js → test/placefinder.test.js
@@ -26,3 +26,22 @@ exports.woeid = function(t) {
t.done();
});
};
+
+exports.city = function(t) {
+ var pf = new PlaceFinder(appID);
+ var city = "Hermosa B";
+ pf.city(city, function(err, data) {
+ t.equal(data.ResultSet.Found, 1);
+ t.equal(data.ResultSet.Results[0].city, "Hermosa Beach");
+ t.done();
+ });
+};
+
+exports.zip = function(t) {
+ var pf = new PlaceFinder(appID);
+ var zip = "90254";
+ pf.zip(zip, function(err, data) {
+ t.equal(data.ResultSet.Results[0].city, "Hermosa Beach");
+ t.done();
+ });
+};

0 comments on commit db33793

Please sign in to comment.