1'use strict'; 2require('../common'); 3const assert = require('assert'); 4 5// This test ensures that assert.CallTracker.verify() works as intended. 6 7const tracker = new assert.CallTracker(); 8 9const msg = 'Function(s) were not called the expected number of times'; 10 11function foo() {} 12 13const callsfoo = tracker.calls(foo, 1); 14 15// Expects an error as callsfoo() was called less than one time. 16assert.throws( 17 () => tracker.verify(), 18 { message: msg } 19); 20 21callsfoo(); 22 23// Will throw an error if callsfoo() isn't called exactly once. 24tracker.verify(); 25 26callsfoo(); 27 28// Expects an error as callsfoo() was called more than once. 29assert.throws( 30 () => tracker.verify(), 31 { message: msg } 32); 33