Skip to content

Commit 2646599

Browse files
authored
docs(prefer-called-with): remove references to toBeCalled matcher (#1874)
1 parent a12bc33 commit 2646599

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ Manually fixable by
360360
| [padding-around-describe-blocks](docs/rules/padding-around-describe-blocks.md) | Enforce padding around `describe` blocks | | | 🔧 | |
361361
| [padding-around-expect-groups](docs/rules/padding-around-expect-groups.md) | Enforce padding around `expect` groups | | | 🔧 | |
362362
| [padding-around-test-blocks](docs/rules/padding-around-test-blocks.md) | Enforce padding around `test` and `it` blocks | | | 🔧 | |
363-
| [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()` | | | | |
363+
| [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toHaveBeenCalledWith()` | | | | |
364364
| [prefer-comparison-matcher](docs/rules/prefer-comparison-matcher.md) | Suggest using the built-in comparison matchers | | | 🔧 | |
365365
| [prefer-each](docs/rules/prefer-each.md) | Prefer using `.each` rather than manual loops | | | | |
366366
| [prefer-ending-with-an-expect](docs/rules/prefer-ending-with-an-expect.md) | Prefer having the last statement in a test be an assertion | | | | |

docs/rules/prefer-called-with.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()` (`prefer-called-with`)
1+
# Suggest using `toHaveBeenCalledWith()` (`prefer-called-with`)
22

33
<!-- end auto-generated rule header -->
44

5-
The `toBeCalled()` matcher is used to assert that a mock function has been
5+
The `toHaveBeenCalled()` matcher is used to assert that a mock function has been
66
called one or more times, without checking the arguments passed. The assertion
7-
is stronger when arguments are also validated using the `toBeCalledWith()`
7+
is stronger when arguments are also validated using the `toHaveBeenCalledWith()`
88
matcher. When some arguments are difficult to check, using generic match like
99
`expect.anything()` at least enforces number and position of arguments.
1010

@@ -24,11 +24,14 @@ expect(someFunction).toHaveBeenCalled();
2424
The following patterns are not warnings:
2525

2626
```js
27-
expect(noArgsFunction).toBeCalledWith();
27+
expect(noArgsFunction).toHaveBeenCalledWith();
2828

29-
expect(roughArgsFunction).toBeCalledWith(expect.anything(), expect.any(Date));
29+
expect(roughArgsFunction).toHaveBeenCalledWith(
30+
expect.anything(),
31+
expect.any(Date),
32+
);
3033

31-
expect(anyArgsFunction).toBeCalledTimes(1);
34+
expect(anyArgsFunction).toHaveBeenCalledTimes(1);
3235

33-
expect(uncalledFunction).not.toBeCalled();
36+
expect(uncalledFunction).not.toHaveBeenCalled();
3437
```

src/rules/prefer-called-with.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ export default createRule({
44
name: __filename,
55
meta: {
66
docs: {
7-
description:
8-
'Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()`',
7+
description: 'Suggest using `toHaveBeenCalledWith()`',
98
},
109
messages: {
1110
preferCalledWith: 'Prefer {{ matcherName }}With(/* expected args */)',

0 commit comments

Comments
 (0)