GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test_runner: use validateStringArray for `timers.enable()` · nodejs/node@141e9fe

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/test_runner/mock
    • mock_timers.js
  • test/parallel
    • test-runner-mock-timers.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/test_runner/mock/mock_timers.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/mock/mock_timers.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const {
2323

2424
const {
2525
validateAbortSignal,
26-
validateArray,
2726
validateNumber,
27+
validateStringArray,
2828
} = require('internal/validators');
2929

3030
const {
@@ -676,7 +676,7 @@ class MockTimers {
676676
*/
677677
/**
678678
* Enables the MockTimers replacing the native timers with the fake ones.
679-
* @param {EnableOptions} options
679+
* @param {EnableOptions} [options]
680680
*/
681681
enable(options = { __proto__: null, apis: SUPPORTED_APIS, now: 0 }) {
682682
const internalOptions = { __proto__: null, ...options };
@@ -696,7 +696,7 @@ class MockTimers {
696696
internalOptions.apis = SUPPORTED_APIS;
697697
}
698698

699-
validateArray(internalOptions.apis, 'options.apis');
699+
validateStringArray(internalOptions.apis, 'options.apis');
700700
// Check that the timers passed are supported
701701
ArrayPrototypeForEach(internalOptions.apis, (timer) => {
702702
if (!ArrayPrototypeIncludes(SUPPORTED_APIS, timer)) {
Collapse file

‎test/parallel/test-runner-mock-timers.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-runner-mock-timers.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ describe('Mock Timers Test Suite', () => {
1717
});
1818
});
1919

20+
it('should throw an error if data type of trying to enable a timer is not string', (t) => {
21+
assert.throws(() => {
22+
t.mock.timers.enable({ apis: [1] });
23+
}, {
24+
code: 'ERR_INVALID_ARG_TYPE',
25+
});
26+
});
27+
2028
it('should throw an error if trying to enable a timer twice', (t) => {
2129
t.mock.timers.enable();
2230
assert.throws(() => {

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.