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 2024-05-27 23:22:45 +09:00 committed by GitHub
parent bd151552ef
commit 33d4f29911
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2234,10 +2234,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);
});
@ -2253,10 +2253,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);
});
@ -2306,8 +2306,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';
@ -2320,7 +2320,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);
@ -2340,7 +2340,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);