Skip to content

Commit b0f751e

Browse files
authored
docs: cleanup mock.calls structure (#10942)
1 parent 04a914a commit b0f751e

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

docs/MockFunctions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ const result = [11, 12].filter(num => filterTestFn(num));
105105

106106
console.log(result);
107107
// > [11]
108-
console.log(filterTestFn.mock.calls);
109-
// > [ [11], [12] ]
108+
console.log(filterTestFn.mock.calls[0][0]); // 11
109+
console.log(filterTestFn.mock.calls[0][1]); // 12
110110
```
111111

112112
Most real-world examples actually involve getting ahold of a mock function on a dependent component and configuring that, but the technique is the same. In these cases, try to avoid the temptation to implement logic inside of any function that's not directly being tested.

website/versioned_docs/version-22.x/MockFunctions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ const result = [11, 12].filter(num => filterTestFn(num));
100100

101101
console.log(result);
102102
// > [11]
103-
console.log(filterTestFn.mock.calls);
104-
// > [ [11], [12] ]
103+
console.log(filterTestFn.mock.calls[0][0]); // 11
104+
console.log(filterTestFn.mock.calls[0][1]); // 12
105105
```
106106

107107
Most real-world examples actually involve getting ahold of a mock function on a dependent component and configuring that, but the technique is the same. In these cases, try to avoid the temptation to implement logic inside of any function that's not directly being tested.

website/versioned_docs/version-23.x/MockFunctions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ const result = [11, 12].filter(num => filterTestFn(num));
106106

107107
console.log(result);
108108
// > [11]
109-
console.log(filterTestFn.mock.calls);
110-
// > [ [11], [12] ]
109+
console.log(filterTestFn.mock.calls[0][0]); // 11
110+
console.log(filterTestFn.mock.calls[0][1]); // 12
111111
```
112112

113113
Most real-world examples actually involve getting ahold of a mock function on a dependent component and configuring that, but the technique is the same. In these cases, try to avoid the temptation to implement logic inside of any function that's not directly being tested.

0 commit comments

Comments
 (0)