| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4e848d4 commit b3032d2
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,56 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + // Flags: --expose-internals | ||
| 3 | + | ||
| 4 | + // This test ensures that the type checking of ModuleMap throws | ||
| 5 | + // errors appropriately | ||
| 6 | + | ||
| 7 | + const common = require('../common'); | ||
| 8 | + | ||
| 9 | + const { URL } = require('url'); | ||
| 10 | + const Loader = require('internal/loader/Loader'); | ||
| 11 | + const ModuleMap = require('internal/loader/ModuleMap'); | ||
| 12 | + const ModuleJob = require('internal/loader/ModuleJob'); | ||
| 13 | + const { createDynamicModule } = require('internal/loader/ModuleWrap'); | ||
| 14 | + | ||
| 15 | + const stubModuleUrl = new URL('file://tmp/test'); | ||
| 16 | + const stubModule = createDynamicModule(['default'], stubModuleUrl); | ||
| 17 | + const loader = new Loader(); | ||
| 18 | + const moduleMap = new ModuleMap(); | ||
| 19 | + const moduleJob = new ModuleJob(loader, stubModule.module, | ||
| 20 | + () => new Promise(() => {})); | ||
| 21 | + | ||
| 22 | + common.expectsError( | ||
| 23 | + () => moduleMap.get(1), | ||
| 24 | + { | ||
| 25 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 26 | + type: TypeError, | ||
| 27 | + message: 'The "url" argument must be of type string' | ||
| 28 | + } | ||
| 29 | + ); | ||
| 30 | + | ||
| 31 | + common.expectsError( | ||
| 32 | + () => moduleMap.set(1, moduleJob), | ||
| 33 | + { | ||
| 34 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 35 | + type: TypeError, | ||
| 36 | + message: 'The "url" argument must be of type string' | ||
| 37 | + } | ||
| 38 | + ); | ||
| 39 | + | ||
| 40 | + common.expectsError( | ||
| 41 | + () => moduleMap.set('somestring', 'notamodulejob'), | ||
| 42 | + { | ||
| 43 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 44 | + type: TypeError, | ||
| 45 | + message: 'The "job" argument must be of type ModuleJob' | ||
| 46 | + } | ||
| 47 | + ); | ||
| 48 | + | ||
| 49 | + common.expectsError( | ||
| 50 | + () => moduleMap.has(1), | ||
| 51 | + { | ||
| 52 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 53 | + type: TypeError, | ||
| 54 | + message: 'The "url" argument must be of type string' | ||
| 55 | + } | ||
| 56 | + ); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments