Comparing version 0.0.8 to 0.0.9
@@ -6,3 +6,2 @@ var mod = require('module'); | ||
function loadHook(request,parent,isMain) { | ||
@@ -16,2 +15,11 @@ return partialMock(request,parent,isMain); | ||
loadHook._aClearMocks = function(){ | ||
mod._load = originalLoad; | ||
if (mod._load._aClearMocks) | ||
mod._load._aClearMocks(); | ||
}; | ||
expect.clear = loadHook._aClearMocks; | ||
module.exports = expect; |
@@ -43,1 +43,19 @@ var sut = require('../expectRequire'); | ||
})(); | ||
(function(){ | ||
console.log('expectRequire clear'); | ||
(function() { | ||
console.log('require'); | ||
sut('./foo').return(fooFake); | ||
sut.clear(); | ||
var returned = require('./foo'); | ||
test('it should execute returns real foo', function(){ | ||
assert.notEqual(fooFake,returned); | ||
}); | ||
})(); | ||
})(); |
{ | ||
"name": "a_mock", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "title": "a_mock", |
@@ -10,4 +10,6 @@ var newMock = require('./mock'); | ||
create.clear = expectRequire.clear; | ||
module.exports = create; | ||
@@ -8,2 +8,3 @@ var assert = require('assert'); | ||
var expectRequireMock = newMock(); | ||
expectRequireMock.clear = {}; | ||
@@ -25,5 +26,5 @@ expectRequire('./mock').return(newMockMock); | ||
returnMock.expect(mock).whenCalled(onReturnMock).return(null); | ||
var sut = require('../requireMock'); | ||
var returned = sut(moduleName); | ||
var returned = require('../requireMock')(moduleName); | ||
function onReturnMock() { | ||
@@ -41,2 +42,7 @@ didExpectRequireReturnMock = true; | ||
test('clear should point at expectRequire.clear',function(){ | ||
assert.equal(sut.clear, expectRequireMock.clear); | ||
}); | ||
})(); |
118640
3836