hapi-methods
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -16,5 +16,5 @@ var _ = require('underscore'), | ||
var args = _.take(arguments, arguments.length-2); | ||
var sha = sha(JSON.stringify(args)); | ||
server.log(["key-generate"], { args: args, key: sha }); | ||
return sha; | ||
var key = sha(JSON.stringify(args)); | ||
server.log(["key-generate"], { args: args, key: key }); | ||
return key; | ||
} | ||
@@ -21,0 +21,0 @@ }); |
{ | ||
"name": "hapi-methods", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "server method helper", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,8 +7,12 @@ var should = require('should'), | ||
ms = [], | ||
logs = []; | ||
logs = [], | ||
serverlogs = []; | ||
describe('tests', function(){ | ||
var server = { | ||
method: function(n, m){ | ||
ms.push(m); | ||
method: function(n, m, c){ | ||
ms.push({ m: m, c: c }); | ||
}, | ||
log: function(t, v){ | ||
serverlogs.push(v); | ||
} | ||
@@ -33,3 +37,3 @@ }, | ||
it('should log a cachemiss', function(){ | ||
ms[0](2, 2, request, function(err, res){ | ||
ms[0].m(2, 2, request, function(err, res){ | ||
logs.length.should.eql(1); | ||
@@ -42,2 +46,13 @@ }); | ||
}); | ||
it('should register the generateKey function', function(){ | ||
var result = ms[0].c.generateKey(2, 2, request, function(err, res){}); | ||
result.should.eql('251a8ad2b3294251a16936bf66f9bc747b5e9fb3'); | ||
}); | ||
it('should log the key and args when invoked', function(){ | ||
ms[0].c.generateKey(2, 2, request, function(err, res){}); | ||
serverlogs[0].key.should.eql('251a8ad2b3294251a16936bf66f9bc747b5e9fb3'); | ||
serverlogs[0].args.should.eql([2, 2]); | ||
}); | ||
}); |
8776
183