From bea753aaf82e5486632a782745e3f39157088af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20R=C3=A8gne?= Date: Thu, 11 Jul 2024 19:11:05 +0200 Subject: [PATCH] doc: use mock.callCount() in examples PR-URL: https://github.com/nodejs/node/pull/53754 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Moshe Atlow Reviewed-By: Trivikram Kamat Reviewed-By: Raz Luvaton --- doc/api/test.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/api/test.md b/doc/api/test.md index 2dc9ad967d3b6a..364f300cc99eeb 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -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]); @@ -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]); @@ -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]; @@ -2027,9 +2027,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];