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 <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Raz Luvaton <rluvaton@gmail.com>
  • Loading branch information
regseb authored and marco-ippolito committed Aug 19, 2024
1 parent f64db24 commit e71aa7e
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 @@ -497,9 +497,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 @@ -521,9 +521,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 @@ -551,9 +551,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 @@ -1854,9 +1854,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 e71aa7e

Please sign in to comment.