blob: 75d20bf9c49c38268d0306c7bc8a3a6a38c0ab26 [file] [edit]
'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 }
);