From e5bf787daff9458d538176c0a0e1f5ec821fe780 Mon Sep 17 00:00:00 2001 From: Deokjin Kim Date: Mon, 27 May 2024 23:22:45 +0900 Subject: [PATCH] doc: fix wrong variable name in example of `timers.tick()` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change variable name from `twoSeconds` to `threeSeconds` because actual value is 3000(ms). And add missing supported timer value(clearImmediate). Plus, fix typo(implicity -> implicitly). PR-URL: https://github.com/nodejs/node/pull/53147 Reviewed-By: Colin Ihrig Reviewed-By: Chemi Atlow Reviewed-By: Moshe Atlow Reviewed-By: Ulises Gascón --- doc/api/test.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/api/test.md b/doc/api/test.md index 013adad5e7ea97..a55785ac69264b 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -2237,10 +2237,10 @@ test('mocks setTimeout to be executed synchronously without having to actually w const nineSecs = 9000; setTimeout(fn, nineSecs); - const twoSeconds = 3000; - context.mock.timers.tick(twoSeconds); - context.mock.timers.tick(twoSeconds); - context.mock.timers.tick(twoSeconds); + const threeSeconds = 3000; + context.mock.timers.tick(threeSeconds); + context.mock.timers.tick(threeSeconds); + context.mock.timers.tick(threeSeconds); assert.strictEqual(fn.mock.callCount(), 1); }); @@ -2256,10 +2256,10 @@ test('mocks setTimeout to be executed synchronously without having to actually w const nineSecs = 9000; setTimeout(fn, nineSecs); - const twoSeconds = 3000; - context.mock.timers.tick(twoSeconds); - context.mock.timers.tick(twoSeconds); - context.mock.timers.tick(twoSeconds); + const threeSeconds = 3000; + context.mock.timers.tick(threeSeconds); + context.mock.timers.tick(threeSeconds); + context.mock.timers.tick(threeSeconds); assert.strictEqual(fn.mock.callCount(), 1); }); @@ -2309,8 +2309,8 @@ test('mocks setTimeout to be executed synchronously without having to actually w #### Using clear functions -As mentioned, all clear functions from timers (`clearTimeout` and `clearInterval`) -are implicity mocked. Take a look at this example using `setTimeout`: +As mentioned, all clear functions from timers (`clearTimeout`, `clearInterval`,and +`clearImmediate`) are implicitly mocked. Take a look at this example using `setTimeout`: ```mjs import assert from 'node:assert'; @@ -2323,7 +2323,7 @@ test('mocks setTimeout to be executed synchronously without having to actually w context.mock.timers.enable({ apis: ['setTimeout'] }); const id = setTimeout(fn, 9999); - // Implicity mocked as well + // Implicitly mocked as well clearTimeout(id); context.mock.timers.tick(9999); @@ -2343,7 +2343,7 @@ test('mocks setTimeout to be executed synchronously without having to actually w context.mock.timers.enable({ apis: ['setTimeout'] }); const id = setTimeout(fn, 9999); - // Implicity mocked as well + // Implicitly mocked as well clearTimeout(id); context.mock.timers.tick(9999);