Skip to content

Commit 698ca4c

Browse files
committed
updated documentation
1 parent dd4a04a commit 698ca4c

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

README.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
# substitute.js
21
[`@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.
32

4-
## Installing
3+
# Installing
54
`npm install @fluffy-spoon/substitute --save-dev`
65

7-
## Requirements
6+
# Requirements
87
* `TypeScript^3.0.0`
98

10-
## Usage
11-
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!
12-
9+
# Usage
1310
```typescript
1411
import { Substitute, Arg } from '@fluffy-spoon/substitute';
1512

@@ -28,11 +25,11 @@ calculator.received().add(1, Arg.any());
2825
calculator.didNotReceive().add(2, 2);
2926
```
3027

31-
### Creating a mock
32-
`var myFakeCalculator = Substitute.for<Calculator>();`
28+
## Creating a mock
29+
`var calculator = Substitute.for<Calculator>();`
3330

34-
### Setting return types
35-
See the example below.
31+
## Setting return types
32+
See the example below. The same syntax also applies to properties and fields.
3633

3734
```typescript
3835
//single return type
@@ -48,8 +45,8 @@ console.log(calculator.add(1, 2)); //prints 9
4845
console.log(calculator.add(1, 2)); //prints undefined
4946
```
5047

51-
### Argument matchers
52-
There are several ways of matching arguments. You don't have to be explicit.
48+
## Argument matchers
49+
There are several ways of matching arguments. The examples below also applies to properties and fields.
5350

5451
```typescript
5552
import { Arg } from '@fluffy-spoon/substitute';
@@ -61,7 +58,4 @@ console.log(calculator.add(1337, 2)); //prints 10 since second argument matches
6158

6259
//received call with first arg 1 and second arg less than 0
6360
calculator.received().add(1, Arg.is(x => x < 0));
64-
```
65-
66-
## What is this - black magic?
67-
`@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.
61+
```

0 commit comments

Comments
 (0)