GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: use mock.callCount() in examples · nodejs/node@e71aa7e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • test.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/test.md‎

Copy file name to clipboardExpand all lines: doc/api/test.md
+8-8Lines changed: 8 additions & 8 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,9 @@ test('spies on a function', () => {
497497
return a + b;
498498
});
499499

500-
assert.strictEqual(sum.mock.calls.length, 0);
500+
assert.strictEqual(sum.mock.callCount(), 0);
501501
assert.strictEqual(sum(3, 4), 7);
502-
assert.strictEqual(sum.mock.calls.length, 1);
502+
assert.strictEqual(sum.mock.callCount(), 1);
503503

504504
const call = sum.mock.calls[0];
505505
assert.deepStrictEqual(call.arguments, [3, 4]);
@@ -521,9 +521,9 @@ test('spies on a function', () => {
521521
return a + b;
522522
});
523523

524-
assert.strictEqual(sum.mock.calls.length, 0);
524+
assert.strictEqual(sum.mock.callCount(), 0);
525525
assert.strictEqual(sum(3, 4), 7);
526-
assert.strictEqual(sum.mock.calls.length, 1);
526+
assert.strictEqual(sum.mock.callCount(), 1);
527527

528528
const call = sum.mock.calls[0];
529529
assert.deepStrictEqual(call.arguments, [3, 4]);
@@ -551,9 +551,9 @@ test('spies on an object method', (t) => {
551551
};
552552

553553
t.mock.method(number, 'add');
554-
assert.strictEqual(number.add.mock.calls.length, 0);
554+
assert.strictEqual(number.add.mock.callCount(), 0);
555555
assert.strictEqual(number.add(3), 8);
556-
assert.strictEqual(number.add.mock.calls.length, 1);
556+
assert.strictEqual(number.add.mock.callCount(), 1);
557557

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

@@ -1854,9 +1854,9 @@ test('spies on an object method', (t) => {
18541854
};
18551855

18561856
t.mock.method(number, 'subtract');
1857-
assert.strictEqual(number.subtract.mock.calls.length, 0);
1857+
assert.strictEqual(number.subtract.mock.callCount(), 0);
18581858
assert.strictEqual(number.subtract(3), 2);
1859-
assert.strictEqual(number.subtract.mock.calls.length, 1);
1859+
assert.strictEqual(number.subtract.mock.callCount(), 1);
18601860

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

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.