mirror of
https://github.com/nodejs/node.git
synced 2025-05-03 16:34:41 +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
683 B
JavaScript
33 lines
683 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
// This test ensures that assert.CallTracker.verify() works as intended.
|
|
|
|
const tracker = new assert.CallTracker();
|
|
|
|
const msg = 'Function(s) were not called the expected number of times';
|
|
|
|
function foo() {}
|
|
|
|
const callsfoo = tracker.calls(foo, 1);
|
|
|
|
// Expects an error as callsfoo() was called less than one time.
|
|
assert.throws(
|
|
() => tracker.verify(),
|
|
{ message: msg }
|
|
);
|
|
|
|
callsfoo();
|
|
|
|
// Will throw an error if callsfoo() isn't called exactly once.
|
|
tracker.verify();
|
|
|
|
callsfoo();
|
|
|
|
// Expects an error as callsfoo() was called more than once.
|
|
assert.throws(
|
|
() => tracker.verify(),
|
|
{ message: msg }
|
|
);
|