Skip to content

Commit

Permalink
docs: add "shorthand for" notes in Mock Function API documentation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mrazauskas committed Jan 15, 2023
1 parent 1a97aa6 commit 7b33879
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/MockFunctionAPI.md
Expand Up @@ -296,6 +296,12 @@ jest.fn(function () {

### `mockFn.mockReturnValue(value)`

Shorthand for:

```js
jest.fn().mockImplementation(() => value);
```

Accepts a value that will be returned whenever the mock function is called.

```js tab
Expand All @@ -320,6 +326,12 @@ mock(); // 43

### `mockFn.mockReturnValueOnce(value)`

Shorthand for:

```js
jest.fn().mockImplementationOnce(() => value);
```

Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`.

```js tab
Expand Down
12 changes: 12 additions & 0 deletions website/versioned_docs/version-25.x/MockFunctionAPI.md
Expand Up @@ -210,6 +210,12 @@ jest.fn(function () {

### `mockFn.mockReturnValue(value)`

Shorthand for:

```js
jest.fn().mockImplementation(() => value);
```

Accepts a value that will be returned whenever the mock function is called.

```js
Expand All @@ -222,6 +228,12 @@ mock(); // 43

### `mockFn.mockReturnValueOnce(value)`

Shorthand for:

```js
jest.fn().mockImplementationOnce(() => value);
```

Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`.

```js
Expand Down
12 changes: 12 additions & 0 deletions website/versioned_docs/version-26.x/MockFunctionAPI.md
Expand Up @@ -210,6 +210,12 @@ jest.fn(function () {

### `mockFn.mockReturnValue(value)`

Shorthand for:

```js
jest.fn().mockImplementation(() => value);
```

Accepts a value that will be returned whenever the mock function is called.

```js
Expand All @@ -222,6 +228,12 @@ mock(); // 43

### `mockFn.mockReturnValueOnce(value)`

Shorthand for:

```js
jest.fn().mockImplementationOnce(() => value);
```

Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`.

```js
Expand Down
12 changes: 12 additions & 0 deletions website/versioned_docs/version-27.x/MockFunctionAPI.md
Expand Up @@ -220,6 +220,12 @@ jest.fn(function () {

### `mockFn.mockReturnValue(value)`

Shorthand for:

```js
jest.fn().mockImplementation(() => value);
```

Accepts a value that will be returned whenever the mock function is called.

```js
Expand All @@ -232,6 +238,12 @@ mock(); // 43

### `mockFn.mockReturnValueOnce(value)`

Shorthand for:

```js
jest.fn().mockImplementationOnce(() => value);
```

Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`.

```js
Expand Down
12 changes: 12 additions & 0 deletions website/versioned_docs/version-28.x/MockFunctionAPI.md
Expand Up @@ -296,6 +296,12 @@ jest.fn(function () {

### `mockFn.mockReturnValue(value)`

Shorthand for:

```js
jest.fn().mockImplementation(() => value);
```

Accepts a value that will be returned whenever the mock function is called.

```js tab
Expand All @@ -320,6 +326,12 @@ mock(); // 43

### `mockFn.mockReturnValueOnce(value)`

Shorthand for:

```js
jest.fn().mockImplementationOnce(() => value);
```

Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`.

```js tab
Expand Down
12 changes: 12 additions & 0 deletions website/versioned_docs/version-29.0/MockFunctionAPI.md
Expand Up @@ -296,6 +296,12 @@ jest.fn(function () {

### `mockFn.mockReturnValue(value)`

Shorthand for:

```js
jest.fn().mockImplementation(() => value);
```

Accepts a value that will be returned whenever the mock function is called.

```js tab
Expand All @@ -320,6 +326,12 @@ mock(); // 43

### `mockFn.mockReturnValueOnce(value)`

Shorthand for:

```js
jest.fn().mockImplementationOnce(() => value);
```

Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`.

```js tab
Expand Down
12 changes: 12 additions & 0 deletions website/versioned_docs/version-29.1/MockFunctionAPI.md
Expand Up @@ -296,6 +296,12 @@ jest.fn(function () {

### `mockFn.mockReturnValue(value)`

Shorthand for:

```js
jest.fn().mockImplementation(() => value);
```

Accepts a value that will be returned whenever the mock function is called.

```js tab
Expand All @@ -320,6 +326,12 @@ mock(); // 43

### `mockFn.mockReturnValueOnce(value)`

Shorthand for:

```js
jest.fn().mockImplementationOnce(() => value);
```

Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`.

```js tab
Expand Down
12 changes: 12 additions & 0 deletions website/versioned_docs/version-29.2/MockFunctionAPI.md
Expand Up @@ -296,6 +296,12 @@ jest.fn(function () {

### `mockFn.mockReturnValue(value)`

Shorthand for:

```js
jest.fn().mockImplementation(() => value);
```

Accepts a value that will be returned whenever the mock function is called.

```js tab
Expand All @@ -320,6 +326,12 @@ mock(); // 43

### `mockFn.mockReturnValueOnce(value)`

Shorthand for:

```js
jest.fn().mockImplementationOnce(() => value);
```

Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`.

```js tab
Expand Down
12 changes: 12 additions & 0 deletions website/versioned_docs/version-29.3/MockFunctionAPI.md
Expand Up @@ -296,6 +296,12 @@ jest.fn(function () {

### `mockFn.mockReturnValue(value)`

Shorthand for:

```js
jest.fn().mockImplementation(() => value);
```

Accepts a value that will be returned whenever the mock function is called.

```js tab
Expand All @@ -320,6 +326,12 @@ mock(); // 43

### `mockFn.mockReturnValueOnce(value)`

Shorthand for:

```js
jest.fn().mockImplementationOnce(() => value);
```

Accepts a value that will be returned for one call to the mock function. Can be chained so that successive calls to the mock function return different values. When there are no more `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`.

```js tab
Expand Down

0 comments on commit 7b33879

Please sign in to comment.