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

jasmine-auto-spies

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jasmine-auto-spies - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

2

package.json
{
"name": "jasmine-auto-spies",
"version": "3.2.0",
"version": "3.2.1",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

@@ -208,3 +208,3 @@ # jasmine-auto-spies

Now you can use the `nextWith` or `throwWith` methods -
Now you can use the `nextWith` or `throwWith` and other methods -

@@ -221,5 +221,9 @@ ```ts

it( ()=>{
myServiceSpy.getProducts.and.nextWith( fakeProductsList);
myServiceSpy.getProducts.and.nextWith( fakeProductsList );
// OR
myServiceSpy.getProducts.and.nextOneTimeWith( fakeProductsList ); // emits one value and completes
// OR
myServiceSpy.getProducts.and.throwWith( fakeError );
// OR
myServiceSpy.getProducts.and.complete();
});

@@ -229,3 +233,32 @@

### Use `calledWith()` to configure mocks easily
You can setup the expected arguments ahead of time
by using `calledWith` like so:
```ts
myServiceSpy.getProducts.calledWith(1).returnValue(true)
```
is equal to:
```ts
myServiceSpy.getProducts.and.returnValue(true)
expect(myServiceSpy.getProducts).toHaveBeenCalledWith(1);
```
You can also use it with async method:
```ts
myServiceSpy.getProducts.calledWith(1).resolveWith(true)
// OR
myServiceSpy.getProducts.calledWith(1).nextWith(true)
// OR ANY OTHER ASYNC CONFIGURATION METHOD...
```
### Manual Setup

@@ -232,0 +265,0 @@

@@ -18,10 +18,6 @@ "use strict";

var spyMethod = createSpyFunction(methodName);
if ((providedPromiseMethodNames &&
providedPromiseMethodNames.indexOf(methodName) !== -1) ||
returnTypeClass === Promise) {
if (doesMethodReturnPromise(providedPromiseMethodNames, methodName, returnTypeClass)) {
autoSpy[methodName] = createPromiseSpyFunction(spyMethod);
}
else if ((providedObservableMethodNames &&
providedObservableMethodNames.indexOf(methodName) !== -1) ||
returnTypeClass === rxjs_1.Observable) {
else if (doesMethodReturnObservable(providedObservableMethodNames, methodName, returnTypeClass)) {
autoSpy[methodName] = createObservableSpyFunction(spyMethod);

@@ -178,2 +174,11 @@ }

}
function doesMethodReturnPromise(promiseMethodsList, methodName, returnTypeClass) {
return ((promiseMethodsList && promiseMethodsList.indexOf(methodName) !== -1) ||
returnTypeClass === Promise);
}
function doesMethodReturnObservable(observableMethodsList, methodName, returnTypeClass) {
return ((observableMethodsList && observableMethodsList.indexOf(methodName) !== -1) ||
returnTypeClass === rxjs_1.Observable ||
(returnTypeClass && returnTypeClass.prototype instanceof rxjs_1.Observable));
}
function getAllMethodNames(obj) {

@@ -180,0 +185,0 @@ var methods = [];

@@ -1,2 +0,2 @@

import { Observable } from 'rxjs';
import { Observable, Subject } from 'rxjs';
export declare class FakeClass {

@@ -8,2 +8,3 @@ someProp: number;

observableMethod(): Observable<void>;
subjectMethod(): Subject<any>;
providedObservableMethod(): Observable<void>;

@@ -10,0 +11,0 @@ }

@@ -40,2 +40,5 @@ "use strict";

};
FakeClass.prototype.subjectMethod = function () {
return new rxjs_1.Subject();
};
FakeClass.prototype.providedObservableMethod = function () {

@@ -56,2 +59,8 @@ return rxjs_1.of();

], FakeClass.prototype, "observableMethod", null);
__decorate([
async_spyable_decorator_1.AsyncSpyable(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", rxjs_1.Subject)
], FakeClass.prototype, "subjectMethod", null);
return FakeClass;

@@ -58,0 +67,0 @@ }());

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