| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e70711e commit 141e9fe
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,8 +23,8 @@ const { | |||
| 23 | 23 | ||
| 24 | 24 | const { | |
| 25 | 25 | validateAbortSignal, | |
| 26 | - validateArray, | ||
| 27 | 26 | validateNumber, | |
| 27 | + validateStringArray, | ||
| 28 | 28 | } = require('internal/validators'); | |
| 29 | 29 | ||
| 30 | 30 | const { | |
@@ -676,7 +676,7 @@ class MockTimers { | |||
| 676 | 676 | */ | |
| 677 | 677 | /** | |
| 678 | 678 | * Enables the MockTimers replacing the native timers with the fake ones. | |
| 679 | - * @param {EnableOptions} options | ||
| 679 | + * @param {EnableOptions} [options] | ||
| 680 | 680 | */ | |
| 681 | 681 | enable(options = { __proto__: null, apis: SUPPORTED_APIS, now: 0 }) { | |
| 682 | 682 | const internalOptions = { __proto__: null, ...options }; | |
@@ -696,7 +696,7 @@ class MockTimers { | |||
| 696 | 696 | internalOptions.apis = SUPPORTED_APIS; | |
| 697 | 697 | } | |
| 698 | 698 | ||
| 699 | - validateArray(internalOptions.apis, 'options.apis'); | ||
| 699 | + validateStringArray(internalOptions.apis, 'options.apis'); | ||
| 700 | 700 | // Check that the timers passed are supported | |
| 701 | 701 | ArrayPrototypeForEach(internalOptions.apis, (timer) => { | |
| 702 | 702 | if (!ArrayPrototypeIncludes(SUPPORTED_APIS, timer)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,6 +17,14 @@ describe('Mock Timers Test Suite', () => { | |||
| 17 | 17 | }); | |
| 18 | 18 | }); | |
| 19 | 19 | ||
| 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 | + | ||
| 20 | 28 | it('should throw an error if trying to enable a timer twice', (t) => { | |
| 21 | 29 | t.mock.timers.enable(); | |
| 22 | 30 | assert.throws(() => { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments