From 40e1c33739dbf13cc29bf075043a697ce555a7a3 Mon Sep 17 00:00:00 2001 From: Deokjin Kim Date: Thu, 7 Sep 2023 23:00:22 +0900 Subject: [PATCH] test_runner: use validateStringArray for `timers.enable()` `apis` which is argument of `timers.enable()` is string array. So use `validatStringArray` instead of `validateArray`. And `options` is optional, so update JSDoc. In document, some default value of `timers` are missed such as `setImmediate` and `clearImmediate`. Next, `milliseconds` which is argument of `timers.tick() is optional and default is 1. --- doc/api/test.md | 13 +++++++------ lib/internal/test_runner/mock/mock_timers.js | 6 +++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/doc/api/test.md b/doc/api/test.md index 5f2d3dfad56cd0..a81c1b76cc2fcd 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -1908,10 +1908,11 @@ mock.timers.enable({ apis: ['Date'], now: new Date() }); Alternatively, if you call `mock.timers.enable()` without any parameters: -All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, and `'clearTimeout'`) -will be mocked. The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout` -functions from `node:timers`, `node:timers/promises`, -and `globalThis` will be mocked. As well as the global `Date` object. +All timers (`'setInterval'`, `'clearInterval'`, `'setTimeout'`, `'clearTimeout'`, +`'setImmediate'`, and `'clearImmediate'`) will be mocked. The `setInterval`, +`clearInterval`, `setTimeout`, `clearTimeout`, `'setImmediate'`, and +`'clearImmediate'` functions from `node:timers`, `node:timers/promises`, and +`globalThis` will be mocked. As well as the global `Date` object. ### `timers.reset()` @@ -1942,7 +1943,7 @@ mock.timers.reset(); Calls `timers.reset()`. -### `timers.tick(milliseconds)` +### `timers.tick([milliseconds])`