Comparing version 0.1.6 to 0.1.7
@@ -31,23 +31,5 @@ /* | ||
var assert = require('assert'); | ||
var utils = require('./utils'); | ||
var events = require('events'); | ||
var methods = function(obj) { | ||
var funcs = []; | ||
var methods = Object.getOwnPropertyNames(obj); | ||
if (obj.constructor !== Object) { | ||
_.forEach(obj.constructor.prototype, function(value, property) { | ||
methods.push(property); | ||
}); | ||
} | ||
_.forEach(methods, function(value) { | ||
var member = typeof(obj[value]); | ||
if (member === 'function') { | ||
funcs.push(value); | ||
} | ||
}); | ||
return funcs; | ||
}; | ||
var Expectations = function() { | ||
@@ -64,3 +46,3 @@ | ||
for (var i = 0; i < arguments.length; i++) { | ||
if (value[i] !== args[i]) { | ||
if (JSON.stringify(value[i]) !== JSON.stringify(args[i])) { | ||
found = false; | ||
@@ -149,3 +131,3 @@ break; | ||
var originalTimeoutFunc = setTimeout; | ||
setTimeout = function(delegate, timeout){ | ||
setTimeout = function(delegate, timeout) { | ||
originalTimeoutFunc(delegate, timeout - milliseconds); | ||
@@ -199,3 +181,3 @@ }; | ||
toCallbackWith: toCallbackWith, | ||
toTimeWarp : toTimeWarp, | ||
toTimeWarp: toTimeWarp, | ||
when: when, | ||
@@ -212,6 +194,8 @@ call: call | ||
function wrap(obj) { | ||
var objMethods = methods(obj); | ||
var objMethods = utils.methods(obj); | ||
var self = {}; | ||
var expectMethods = {}; | ||
var setupMethods = {}; | ||
var eventEmitter = new events.EventEmitter(); | ||
utils.proxyFunctions(self, eventEmitter, ['on', 'emit']); | ||
@@ -218,0 +202,0 @@ function setupForMethod(method) { |
{ | ||
"name": "deride", | ||
"description": "Mocking library based on composition", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"homepage": "https://github.com/REAANDREW/deride", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -49,2 +49,14 @@ /* | ||
describe('Eventing', function() { | ||
it('should allow the force of an emit', function(done) { | ||
var bob = deride.stub([]); | ||
bob = deride.wrap(bob); | ||
bob.on('message', function() { | ||
done(); | ||
}); | ||
bob.emit('message', 'payload'); | ||
}); | ||
}); | ||
var fooBarFunction = function(timeout, callback) { | ||
@@ -51,0 +63,0 @@ setTimeout(function() { |
30553
12
559