New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@johanblumenberg/ts-mockito

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@johanblumenberg/ts-mockito - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

1

lib/MethodStubSetter.js

@@ -11,2 +11,3 @@ "use strict";

this.methodToStub = methodToStub;
methodToStub.watcher.invoked();
this.groupIndex = ++MethodStubSetter.globalGroupIndex;

@@ -13,0 +14,0 @@ }

@@ -9,2 +9,3 @@ "use strict";

this.methodCallToStringConverter = new MethodCallToStringConverter_1.MethodCallToStringConverter();
methodToVerify.watcher.invoked();
}

@@ -48,2 +49,3 @@ MethodStubVerificator.prototype.called = function () {

MethodStubVerificator.prototype.calledBefore = function (method) {
method.watcher.invoked();
var firstMethodAction = this.methodToVerify.mocker.getFirstMatchingAction(this.methodToVerify.methodName, this.methodToVerify.matchers);

@@ -70,2 +72,3 @@ var secondMethodAction = method.mocker.getFirstMatchingAction(method.methodName, method.matchers);

MethodStubVerificator.prototype.calledAfter = function (method) {
method.watcher.invoked();
var firstMethodAction = this.methodToVerify.mocker.getFirstMatchingAction(this.methodToVerify.methodName, this.methodToVerify.matchers);

@@ -72,0 +75,0 @@ var secondMethodAction = method.mocker.getFirstMatchingAction(method.methodName, method.matchers);

import { Matcher } from "./matcher/type/Matcher";
import { MethodStubCollection } from "./MethodStubCollection";
import { Mocker } from "./Mock";
declare class Watcher {
private _err;
private _invoked;
constructor(_err: Error);
invoked(): void;
private nextTick;
}
export declare class MethodToStub {

@@ -9,3 +16,5 @@ methodStubCollection: MethodStubCollection;

methodName: string;
watcher: Watcher;
constructor(methodStubCollection: MethodStubCollection, matchers: Matcher[], mocker: Mocker, methodName: string);
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Watcher = (function () {
function Watcher(_err) {
var _this = this;
this._err = _err;
this._invoked = false;
this.nextTick = function () {
if (!_this._invoked) {
throw _this._err;
}
};
setTimeout(this.nextTick, 0);
}
Watcher.prototype.invoked = function () {
this._invoked = true;
};
return Watcher;
}());
var MethodToStub = (function () {

@@ -9,2 +26,3 @@ function MethodToStub(methodStubCollection, matchers, mocker, methodName) {

this.methodName = methodName;
this.watcher = new Watcher(new Error("Unmatched call to " + methodName + " on a mock object, did you mean to use instance()?"));
}

@@ -11,0 +29,0 @@ return MethodToStub;

34

lib/Mock.js

@@ -192,20 +192,2 @@ "use strict";

});
var methodMock = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
isProperty = false;
var matchers = [];
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
var arg = args_1[_a];
if (!(arg instanceof Matcher_1.Matcher)) {
matchers.push(ts_mockito_1.strictEqual(arg));
}
else {
matchers.push(arg);
}
}
return new MethodToStub_1.MethodToStub(_this.methodStubCollections[key], matchers, _this, key);
};
var propertyMock = function () {

@@ -215,3 +197,13 @@ if (!_this.methodStubCollections[key]) {

}
return Object.assign(methodMock, new MethodToStub_1.MethodToStub(_this.methodStubCollections[key], [], _this, key));
var methodToMock = new MethodToStub_1.MethodToStub(_this.methodStubCollections[key], [], _this, key);
var methodMock = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
isProperty = false;
methodToMock.matchers = args.map(function (arg) { return (arg instanceof Matcher_1.Matcher) ? arg : ts_mockito_1.strictEqual(arg); });
return methodToMock;
};
return Object.assign(methodMock, methodToMock);
};

@@ -247,4 +239,4 @@ Object.defineProperty(this.mock, key, {

var matchers = [];
for (var _a = 0, args_2 = args; _a < args_2.length; _a++) {
var arg = args_2[_a];
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
var arg = args_1[_a];
if (!(arg instanceof Matcher_1.Matcher)) {

@@ -251,0 +243,0 @@ matchers.push(ts_mockito_1.strictEqual(arg));

@@ -46,2 +46,3 @@ import { ArgCaptor1, ArgCaptor10, ArgCaptor2, ArgCaptor3, ArgCaptor4, ArgCaptor5, ArgCaptor6, ArgCaptor7, ArgCaptor8, ArgCaptor9 } from "./capture/ArgCaptor";

export declare function defer<T>(): Deferred<T>;
export declare function nextTick(): Promise<void>;
declare const _default: {

@@ -73,3 +74,4 @@ spy: typeof spy;

defer: typeof defer;
nextTick: typeof nextTick;
};
export default _default;

@@ -83,2 +83,3 @@ "use strict";

if (methodStub instanceof MethodToStub_1.MethodToStub) {
methodStub.watcher.invoked();
var actions = methodStub.mocker.getActionsByName(methodStub.methodName);

@@ -162,2 +163,6 @@ return new ArgCaptor_1.ArgCaptor(actions);

exports.defer = defer;
function nextTick() {
return new Promise(function (resolve) { return setTimeout(resolve, 0); });
}
exports.nextTick = nextTick;
exports.default = {

@@ -189,3 +194,4 @@ spy: spy,

defer: defer,
nextTick: nextTick,
};
//# sourceMappingURL=ts-mockito.js.map

@@ -7,2 +7,3 @@ "use strict";

MethodCallToStringConverter.prototype.convert = function (method) {
method.watcher.invoked();
var stringifiedMatchers = method.matchers.map(function (matcher) { return matcher.toString(); }).join(", ");

@@ -9,0 +10,0 @@ return method.methodName + "(" + stringifiedMatchers + ")\" ";

{
"name": "@johanblumenberg/ts-mockito",
"version": "1.0.8",
"version": "1.0.9",
"description": "Mocking library for TypeScript",

@@ -5,0 +5,0 @@ "main": "lib/ts-mockito.js",

@@ -9,2 +9,3 @@ # @johanblumenberg/ts-mockito

- [Add defer() for testing deferred promise resolution](https://github.com/NagRock/ts-mockito/pull/141)
- [Add warning when forgetting to call instance()](https://github.com/johanblumenberg/ts-mockito/commit/e2b52a77324136d8b6a8aabf51eec8babaca221b)

@@ -11,0 +12,0 @@ ## Installation

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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