Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b3032d2

Browse filesBrowse files
robtpatongibfahn
authored andcommitted
test: increase coverage for ModuleMap
Add test for ModuleMap set with ModuleJob but bad url. PR-URL: #16045 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 4e848d4 commit b3032d2
Copy full SHA for b3032d2

File tree

Expand file treeCollapse file tree

1 file changed

+56
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+56
-0
lines changed
Open diff view settings
Collapse file
+56Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.