doc: fix wrong variable name in example of timers.tick()

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 <cjihrig@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
This commit is contained in:
Deokjin Kim authored and Marco Ippolito committed 2024-07-19 15:26:55 +02:00
1 parent 698ea7aa5a
commit 41b08bdcf7
1 file changed
+12 -12
+12 -12
View File
@@ -2098,10 +2098,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);
});
@@ -2117,10 +2117,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);
});
@@ -2170,8 +2170,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';
@@ -2184,7 +2184,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);
@@ -2204,7 +2204,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);