mirror of
https://github.com/nodejs/node.git
synced 2025-05-20 21:13:12 +00:00

Fixes: https://github.com/nodejs/node/issues/31392 PR-URL: https://github.com/nodejs/node/pull/31982 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Zeyu Yang <himself65@outlook.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
33 lines
769 B
JavaScript
33 lines
769 B
JavaScript
'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.
|
|
if (tracker.report()[0].operator !== 'foo') {
|
|
process.exit(1);
|
|
}
|
|
|
|
callsfoo();
|
|
|
|
// Ensures that foo was removed from the callChecks array after being called the
|
|
// expected number of times.
|
|
if (typeof tracker.report()[0] === undefined) {
|
|
process.exit(1);
|
|
}
|
|
|
|
callsfoo();
|
|
|
|
// Ensures that foo was added back to the callChecks array after being called
|
|
// more than the expected number of times.
|
|
if (tracker.report()[0].operator !== 'foo') {
|
|
process.exit(1);
|
|
}
|