| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1ac1fe4 commit 4f421b3
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,8 +26,8 @@ const { | |||
| 26 | 26 | } = primordials; | |
| 27 | 27 | const { | |
| 28 | 28 | validateAbortSignal, | |
| 29 | - validateArray, | ||
| 30 | 29 | validateNumber, | |
| 30 | + validateStringArray, | ||
| 31 | 31 | } = require('internal/validators'); | |
| 32 | 32 | ||
| 33 | 33 | const { | |
@@ -673,7 +673,7 @@ class MockTimers { | |||
| 673 | 673 | */ | |
| 674 | 674 | /** | |
| 675 | 675 | * Enables the MockTimers replacing the native timers with the fake ones. | |
| 676 | - * @param {EnableOptions} options | ||
| 676 | + * @param {EnableOptions} [options] | ||
| 677 | 677 | */ | |
| 678 | 678 | enable(options = { __proto__: null, apis: SUPPORTED_APIS, now: 0 }) { | |
| 679 | 679 | const internalOptions = { __proto__: null, ...options }; | |
@@ -693,7 +693,7 @@ class MockTimers { | |||
| 693 | 693 | internalOptions.apis = SUPPORTED_APIS; | |
| 694 | 694 | } | |
| 695 | 695 | ||
| 696 | - validateArray(internalOptions.apis, 'options.apis'); | ||
| 696 | + validateStringArray(internalOptions.apis, 'options.apis'); | ||
| 697 | 697 | // Check that the timers passed are supported | |
| 698 | 698 | ArrayPrototypeForEach(internalOptions.apis, (timer) => { | |
| 699 | 699 | 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