Skip to content

Commit

Permalink
doc: use mock.callCount() in examples
Browse files Browse the repository at this point in the history
PR-URL: #53754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Raz Luvaton <[email protected]>
  • Loading branch information
regseb authored and aduh95 committed Jul 12, 2024
1 parent b4182a4 commit c7e1064
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions doc/api/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,9 @@ test('spies on a function', () => {
return a + b;
});

assert.strictEqual(sum.mock.calls.length, 0);
assert.strictEqual(sum.mock.callCount(), 0);
assert.strictEqual(sum(3, 4), 7);
assert.strictEqual(sum.mock.calls.length, 1);
assert.strictEqual(sum.mock.callCount(), 1);

const call = sum.mock.calls[0];
assert.deepStrictEqual(call.arguments, [3, 4]);
Expand All @@ -556,9 +556,9 @@ test('spies on a function', () => {
return a + b;
});

assert.strictEqual(sum.mock.calls.length, 0);
assert.strictEqual(sum.mock.callCount(), 0);
assert.strictEqual(sum(3, 4), 7);
assert.strictEqual(sum.mock.calls.length, 1);
assert.strictEqual(sum.mock.callCount(), 1);

const call = sum.mock.calls[0];
assert.deepStrictEqual(call.arguments, [3, 4]);
Expand Down Expand Up @@ -586,9 +586,9 @@ test('spies on an object method', (t) => {
};

t.mock.method(number, 'add');
assert.strictEqual(number.add.mock.calls.length, 0);
assert.strictEqual(number.add.mock.callCount(), 0);
assert.strictEqual(number.add(3), 8);
assert.strictEqual(number.add.mock.calls.length, 1);
assert.strictEqual(number.add.mock.callCount(), 1);

const call = number.add.mock.calls[0];

Expand Down Expand Up @@ -2017,9 +2017,9 @@ test('spies on an object method', (t) => {
};

t.mock.method(number, 'subtract');
assert.strictEqual(number.subtract.mock.calls.length, 0);
assert.strictEqual(number.subtract.mock.callCount(), 0);
assert.strictEqual(number.subtract(3), 2);
assert.strictEqual(number.subtract.mock.calls.length, 1);
assert.strictEqual(number.subtract.mock.callCount(), 1);

const call = number.subtract.mock.calls[0];

Expand Down

0 comments on commit c7e1064

Please sign in to comment.