Skip to content

Commit

Permalink
doc: fix wrong variable name in example of timers.tick()
Browse files Browse the repository at this point in the history
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: #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>
  • Loading branch information
deokjinkim authored and targos committed Jun 1, 2024
1 parent 3bfce6c commit 070577e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions doc/api/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -2226,10 +2226,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);
});
Expand All @@ -2245,10 +2245,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);
});
Expand Down Expand Up @@ -2298,8 +2298,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';
Expand All @@ -2312,7 +2312,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);

Expand All @@ -2332,7 +2332,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);

Expand Down

0 comments on commit 070577e

Please sign in to comment.