mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 21:58:48 +02:00
test: augment tests for SourceTextModule
Adds tests for a few error conditions. Also, adds tests to make sure the dynamically generated url is correct. PR-URL: https://github.com/nodejs/node/pull/23573 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> PR-URL: https://github.com/nodejs/node/pull/23572 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
c596bcc4ff
commit
cac4909bf3
2 changed files with 26 additions and 1 deletions
|
@ -43,7 +43,8 @@ async function checkArgType() {
|
|||
});
|
||||
|
||||
for (const invalidOptions of [
|
||||
0, 1, null, true, 'str', () => {}, { url: 0 }, Symbol.iterator
|
||||
0, 1, null, true, 'str', () => {}, { url: 0 }, Symbol.iterator,
|
||||
{ context: null }, { context: 'hucairz' }, { context: {} }
|
||||
]) {
|
||||
common.expectsError(() => {
|
||||
new SourceTextModule('', invalidOptions);
|
||||
|
@ -231,6 +232,17 @@ async function checkLinking() {
|
|||
});
|
||||
}
|
||||
|
||||
common.expectsError(() => {
|
||||
new SourceTextModule('', {
|
||||
importModuleDynamically: 'hucairz'
|
||||
});
|
||||
}, {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
type: TypeError,
|
||||
message: 'The "options.importModuleDynamically"' +
|
||||
' property must be of type function. Received type string'
|
||||
});
|
||||
|
||||
// Check the JavaScript engine deals with exceptions correctly
|
||||
async function checkExecution() {
|
||||
await (async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue