node/test/parallel/test-assert-calltracker-report.js
Rich Trott adcd60eee6 tools: improve valid-typeof lint rule
Require that `typeof` comparisons be to string literals.

PR-URL: https://github.com/nodejs/node/pull/37924
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-03-28 08:01:44 -07:00

27 lines
741 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.
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');