Skip to content

Commit e5bf787

Browse files
deokjinkimEliphaz Bouye
authored andcommitted
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: nodejs#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>
1 parent 0a266c7 commit e5bf787

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

doc/api/test.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,10 +2237,10 @@ test('mocks setTimeout to be executed synchronously without having to actually w
22372237
const nineSecs = 9000;
22382238
setTimeout(fn, nineSecs);
22392239

2240-
const twoSeconds = 3000;
2241-
context.mock.timers.tick(twoSeconds);
2242-
context.mock.timers.tick(twoSeconds);
2243-
context.mock.timers.tick(twoSeconds);
2240+
const threeSeconds = 3000;
2241+
context.mock.timers.tick(threeSeconds);
2242+
context.mock.timers.tick(threeSeconds);
2243+
context.mock.timers.tick(threeSeconds);
22442244

22452245
assert.strictEqual(fn.mock.callCount(), 1);
22462246
});
@@ -2256,10 +2256,10 @@ test('mocks setTimeout to be executed synchronously without having to actually w
22562256
const nineSecs = 9000;
22572257
setTimeout(fn, nineSecs);
22582258

2259-
const twoSeconds = 3000;
2260-
context.mock.timers.tick(twoSeconds);
2261-
context.mock.timers.tick(twoSeconds);
2262-
context.mock.timers.tick(twoSeconds);
2259+
const threeSeconds = 3000;
2260+
context.mock.timers.tick(threeSeconds);
2261+
context.mock.timers.tick(threeSeconds);
2262+
context.mock.timers.tick(threeSeconds);
22632263

22642264
assert.strictEqual(fn.mock.callCount(), 1);
22652265
});
@@ -2309,8 +2309,8 @@ test('mocks setTimeout to be executed synchronously without having to actually w
23092309

23102310
#### Using clear functions
23112311

2312-
As mentioned, all clear functions from timers (`clearTimeout` and `clearInterval`)
2313-
are implicity mocked. Take a look at this example using `setTimeout`:
2312+
As mentioned, all clear functions from timers (`clearTimeout`, `clearInterval`,and
2313+
`clearImmediate`) are implicitly mocked. Take a look at this example using `setTimeout`:
23142314

23152315
```mjs
23162316
import assert from 'node:assert';
@@ -2323,7 +2323,7 @@ test('mocks setTimeout to be executed synchronously without having to actually w
23232323
context.mock.timers.enable({ apis: ['setTimeout'] });
23242324
const id = setTimeout(fn, 9999);
23252325

2326-
// Implicity mocked as well
2326+
// Implicitly mocked as well
23272327
clearTimeout(id);
23282328
context.mock.timers.tick(9999);
23292329

@@ -2343,7 +2343,7 @@ test('mocks setTimeout to be executed synchronously without having to actually w
23432343
context.mock.timers.enable({ apis: ['setTimeout'] });
23442344
const id = setTimeout(fn, 9999);
23452345

2346-
// Implicity mocked as well
2346+
// Implicitly mocked as well
23472347
clearTimeout(id);
23482348
context.mock.timers.tick(9999);
23492349

0 commit comments

Comments
 (0)