summaryrefslogtreecommitdiff
path: root/test/parallel/test-assert-calltracker-report.js
blob: 87ef0bff17fc0bf0c1847e30cdb02f0f77ee5396 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';
require('../common');
const assert = require('assert');

// This test ensures that the assert.CallTracker.report() works as intended.

const tracker = new assert.CallTracker();

function foo() {}

const callsfoo = tracker.calls(foo, 1);

// Ensures that foo was added to the callChecks array.
assert.strictEqual(tracker.report()[0].operator, 'foo');

callsfoo();

// Ensures that foo was removed from the callChecks array after being called the
// expected number of times.
assert.strictEqual(typeof tracker.report()[0], 'undefined');

callsfoo();

// Ensures that foo was added back to the callChecks array after being called
// more than the expected number of times.
assert.strictEqual(tracker.report()[0].operator, 'foo');