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@4f421b3

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
@@ -26,8 +26,8 @@ const {
2626
} = primordials;
2727
const {
2828
validateAbortSignal,
29-
validateArray,
3029
validateNumber,
30+
validateStringArray,
3131
} = require('internal/validators');
3232

3333
const {
@@ -673,7 +673,7 @@ class MockTimers {
673673
*/
674674
/**
675675
* Enables the MockTimers replacing the native timers with the fake ones.
676-
* @param {EnableOptions} options
676+
* @param {EnableOptions} [options]
677677
*/
678678
enable(options = { __proto__: null, apis: SUPPORTED_APIS, now: 0 }) {
679679
const internalOptions = { __proto__: null, ...options };
@@ -693,7 +693,7 @@ class MockTimers {
693693
internalOptions.apis = SUPPORTED_APIS;
694694
}
695695

696-
validateArray(internalOptions.apis, 'options.apis');
696+
validateStringArray(internalOptions.apis, 'options.apis');
697697
// Check that the timers passed are supported
698698
ArrayPrototypeForEach(internalOptions.apis, (timer) => {
699699
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.