xref: /third_party/node/test/parallel/test-assert-calltracker-report.js (revision 1cb0ef41)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_cirequire('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci// This test ensures that the assert.CallTracker.report() works as intended.
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst tracker = new assert.CallTracker();
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_cifunction foo() {}
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst callsfoo = tracker.calls(foo, 1);
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci// Ensures that foo was added to the callChecks array.
141cb0ef41Sopenharmony_ciassert.strictEqual(tracker.report()[0].operator, 'foo');
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_cicallsfoo();
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci// Ensures that foo was removed from the callChecks array after being called the
191cb0ef41Sopenharmony_ci// expected number of times.
201cb0ef41Sopenharmony_ciassert.strictEqual(typeof tracker.report()[0], 'undefined');
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_cicallsfoo();
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci// Ensures that foo was added back to the callChecks array after being called
251cb0ef41Sopenharmony_ci// more than the expected number of times.
261cb0ef41Sopenharmony_ciassert.strictEqual(tracker.report()[0].operator, 'foo');
27

Indexes created Thu Nov 07 10:32:03 CST 2024