Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

a_mock

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a_mock - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

newObject.js

2

expectRequire.js

@@ -18,5 +18,5 @@ var mod = require('module');

}
expect.clear = mod._requireMock.clear;
expect.reset = mod._requireMock.reset;
module.exports = expect;

@@ -45,3 +45,3 @@ var sut = require('../expectRequire');

(function(){
console.log('expectRequire clear');
console.log('expectRequire reset');

@@ -51,3 +51,3 @@ (function() {

sut('./foo').return(fooFake);
sut.clear();
sut.reset();
var returned = require('./foo');

@@ -54,0 +54,0 @@ sut('./foo').return(fooFake);

{
"name": "a_mock",
"version": "0.1.0",
"version": "0.1.1",
"main": "index.js",

@@ -5,0 +5,0 @@ "title": "a_mock",

@@ -37,3 +37,4 @@ function create(originalFunc) {

mock.ignore = expectAnything;
mock.ignore = mock.expectAnything;
mock.reset = mockContext.reset;

@@ -40,0 +41,0 @@ mock.verify = function() {

@@ -0,14 +1,13 @@

var newObject = require('../newObject')
var reset = require('./mockContext/reset');
function _new(originalFallback) {
var newFallbackWrapper = require('./newFallbackWrapper');
var and = require('../newMutableAnd')();
var mockContext = {};
mockContext.execute = newFallbackWrapper(originalFallback);
mockContext.originalFallback = originalFallback;
mockContext.lastExecute = mockContext.execute;
mockContext.compositeAreCorrectArguments = and;
mockContext.expectCount = 0;
return mockContext;
var c = newObject();
c = reset(c,originalFallback);
c.reset = function() {
return reset(c, originalFallback);
};
return c;
}
module.exports = _new;

@@ -6,4 +6,4 @@ var assert = require('assert');

var newFallbackWrapper = newRequireMock('./newFallbackWrapper');
var newMutableAnd = newRequireMock('../newMutableAnd');
var newObject = newRequireMock('../newObject');
var reset = newRequireMock('./mockContext/reset');

@@ -15,29 +15,24 @@ var newSut = require('../newMockContext');

var originalFallback = {};
var fallbackWrapper = {};
var passedContext;
var mutableAnd = {};
newFallbackWrapper.expect(originalFallback).return(fallbackWrapper);
newMutableAnd.expect().return(mutableAnd);
var didReset;
var object = {};
var context = {};
var resetResult = {};
newObject.expect().return(object);
reset.expect(object).expect(originalFallback).return(context);
var sut = newSut(originalFallback);
test('it should set execute to fallbackWrapper',function() {
assert.equal(sut.execute,fallbackWrapper);
});
test('it should set originalFallback',function() {
assert.equal(sut.originalFallback,originalFallback);
test('it should return context',function() {
assert.equal(sut, context);
});
test('it should set compositeAreCorrectArguments',function() {
assert.equal(sut.compositeAreCorrectArguments,mutableAnd);
});
console.log('reset');
reset.expect(context).expect(originalFallback).return(resetResult);
returned = sut.reset();
test('it should set lastExecute',function() {
assert.equal(sut.lastExecute,fallbackWrapper);
test('forwards to reset',function() {
assert.equal(returned, resetResult);
});
test('it should set expectCount to zero',function() {
assert.equal(sut.expectCount,0);
});
})();

@@ -115,3 +115,3 @@ function create(originalFunc) {

mock.clear = function() {
mock.reset = function() {
mockArray = [];

@@ -118,0 +118,0 @@ };

@@ -67,3 +67,3 @@ var newSut = require('../newPartialMock');

(function() {
console.log('expect return after clear');
console.log('expect return after reset');
var sut = newSut(original);

@@ -74,3 +74,3 @@ sut.expect().return(foo);

var firstReturned = sut();
sut.clear();
sut.reset();
var secondReturned = sut();

@@ -77,0 +77,0 @@ sut.expect().return(foo);

@@ -29,2 +29,3 @@ var test = require('../test');

mockContext = {};
mockContext.reset = {};
newMockContext.expect(fallback).return(mockContext);

@@ -39,5 +40,9 @@ }

test('should set ignore as alias for expectAnything', function() {
assert.equal(c.sut.ignore,c.sut.expectAnything);
assert.equal(sut.ignore, sut.expectAnything);
});
test('reset points at mockContext.reset', function() {
assert.equal(sut.reset, mockContext.reset);
});
(function() {

@@ -44,0 +49,0 @@ console.log('when execute ');

@@ -79,2 +79,17 @@ var assert = require('assert');

test('it should return correct after expect, reset, expect',function() {
var arg = 'a';
var expected = {};
var sut = newSut(fallback);
sut.expect(arg).return(expected);
sut.reset();
var returned = sut(arg);
sut.expect(arg).return(expected);
var returned2 = sut(arg);
var returned3 = sut(arg);
assert.equal(returned,fallbackValue);
assert.equal(returned2,expected);
assert.equal(returned3,fallbackValue);
});
test('it should throw for correct arg',function() {

@@ -81,0 +96,0 @@ var arg = 'a';

@@ -10,3 +10,3 @@ var newMock = require('./mock');

create.clear = expectRequire.clear;
create.reset = expectRequire.reset;

@@ -13,0 +13,0 @@ module.exports = create;

@@ -40,4 +40,4 @@ var assert = require('assert');

test('clear should point at expectRequire.clear',function(){
assert.equal(sut.clear, expectRequireMock.clear);
test('reset should point at expectRequire.reset',function(){
assert.equal(sut.reset, expectRequireMock.reset);
});

@@ -44,0 +44,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc