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

@fluffy-spoon/substitute

Package Overview
Dependencies
Maintainers
1
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fluffy-spoon/substitute - npm Package Compare versions

Comparing version 1.0.50 to 1.0.51

2

package.json
{
"name": "@fluffy-spoon/substitute",
"version": "1.0.50",
"version": "1.0.51",
"description": "An NSubstitute port to TypeScript called substitute.js.",

@@ -5,0 +5,0 @@ "main": "dist/src/Index.js",

@@ -1,13 +0,10 @@

# substitute.js
[`@fluffy-spoon/substitute`](https://www.npmjs.com/package/@fluffy-spoon/substitute) is a TypeScript port of [NSubstitute](http://nsubstitute.github.io), which aims to provide a much more fluent mocking opportunity for strong-typed languages.
## Installing
# Installing
`npm install @fluffy-spoon/substitute --save-dev`
## Requirements
# Requirements
* `TypeScript^3.0.0`
## Usage
Experience full strong-typing of your fakes all the way, and let the TypeScript compiler help with all the dirty work! All methods below have full strong typing all around, even when creating a fake from an interface!
# Usage
```typescript

@@ -31,7 +28,7 @@ import { Substitute, Arg } from '@fluffy-spoon/substitute';

### Creating a mock
`var myFakeCalculator = Substitute.for<Calculator>();`
## Creating a mock
`var calculator = Substitute.for<Calculator>();`
### Setting return types
See the example below.
## Setting return types
See the example below. The same syntax also applies to properties and fields.

@@ -52,4 +49,4 @@ ```typescript

### Argument matchers
There are several ways of matching arguments. You don't have to be explicit.
## Argument matchers
There are several ways of matching arguments. The examples below also applies to properties and fields.

@@ -66,5 +63,2 @@ ```typescript

calculator.received().add(1, Arg.is(x => x < 0));
```
## What is this - black magic?
`@fluffy-spoon/substitute` works the same way that NSubstitute does, except that it uses the EcmaScript 6 `Proxy` class to produce the fakes. You can read more about how NSubstitute works to get inspired.
```
import { ObjectSubstitute } from "./Transformations";
import { ProxyObjectContext, ProxyPropertyContext, ProxyMethodPropertyContext, ProxyCallRecord, ProxyExpectation } from "./Context";
import { stringifyCalls, stringifyArguments } from "./Utilities";
import { access } from "fs";

@@ -6,0 +5,0 @@ export class Substitute {

@@ -1,3 +0,3 @@

import { ProxyPropertyContext, ProxyCallRecord } from "./Context";
import { Arg, Argument } from "./Arguments";
import { ProxyCallRecord } from "./Context";
import { Argument } from "./Arguments";

@@ -4,0 +4,0 @@ export function stringifyArguments(args: any[]) {

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