mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
adcd60eee6
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>
27 lines
741 B
JavaScript
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');
|