Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

extensions

  • Loading branch information...
commit 25d31184171e315bbcf98e6234c52eb0b34d3c1c 1 parent 186cd3d
@jchris authored
Showing with 31 additions and 2 deletions.
  1. +1 −1  lib/hoax-core.js
  2. +30 −1 test/hoax_test.js
View
2  lib/hoax-core.js
@@ -98,7 +98,7 @@ module.exports = function(request) {
};
if (!verb) {
"get put post head del".split(" ").forEach(function(v){
- newHoax[v] = makeHoax(myPax, v);
+ newHoax[v] = makeHoax(myPax, v, newHoax);
});
}
addExtensions(newHoax, oldHoax);
View
31 test/hoax_test.js
@@ -220,6 +220,17 @@ exports['/query'] = {
}
};
+var base = hoax(["http://localhost:3001/very/awesome", {param : "yeah"}]);
+exports['can curry params'] = {
+ 'merges right': function(test) {
+ test.expect(1);
+ base({more : "yep"}, function(err, ok) {
+ test.equal(ok.url, '/very/awesome?param=yeah&more=yep');
+ test.done();
+ });
+ }
+};
+
exports['/error'] = {
setUp: function(done) {
// setup here
@@ -246,8 +257,18 @@ var db;
exports['extensions'] = {
setUp: function(done) {
// setup here
- db = hoax("http://localhost:5984/test-pax", {myKey : "valuable"});
+ handlers['/extensions'] = function(req, res) {
+ var body = "";
+ req.on("data", function(data) {body = body + data;});
+ req.on("end", function(){
+ res.statusCode = 200;
+ res.end(JSON.stringify({url:req.url,awesome:true, method : req.method, body:body}));
+ });
+ };
+
+ db = hoax(["http://localhost:3001/extensions", {myKey : "valuable"}]);
db.extend('mymethod', function(){return 'ok';});
+ db.extend('usethis', function(cb){this([{ice:"cream"}],cb);});
done();
},
'is callable': function(test) {
@@ -256,6 +277,14 @@ exports['extensions'] = {
test.equal(db.mymethod(), 'ok');
test.done();
},
+ 'has working this': function(test) {
+ test.expect(1);
+ // tests here
+ db.usethis(function(err, ok){
+ test.equal(ok.url, '/extensions?myKey=valuable&ice=cream');
+ test.done();
+ });
+ },
'is inherited': function(test) {
test.expect(1);
// tests here
Please sign in to comment.
Something went wrong with that request. Please try again.