mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
test: improve coverage of SourceTextModule getters
PR-URL: https://github.com/nodejs/node/pull/37013 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
fef6ac77e5
commit
de6dca12e8
1 file changed
+14
-4
@@ -235,16 +235,26 @@ function checkInvalidCachedData() {
|
||||
}
|
||||
|
||||
function checkGettersErrors() {
|
||||
const expectedError = {
|
||||
code: 'ERR_VM_MODULE_NOT_MODULE',
|
||||
message: /Provided module is not an instance of Module/
|
||||
};
|
||||
const getters = ['identifier', 'context', 'namespace', 'status', 'error'];
|
||||
getters.forEach((getter) => {
|
||||
assert.throws(() => {
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
Module.prototype[getter];
|
||||
}, {
|
||||
code: 'ERR_VM_MODULE_NOT_MODULE',
|
||||
message: /Provided module is not an instance of Module/
|
||||
});
|
||||
}, expectedError);
|
||||
assert.throws(() => {
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
SourceTextModule.prototype[getter];
|
||||
}, expectedError);
|
||||
});
|
||||
// `dependencySpecifiers` getter is just part of SourceTextModule
|
||||
assert.throws(() => {
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
SourceTextModule.prototype.dependencySpecifiers;
|
||||
}, expectedError);
|
||||
}
|
||||
|
||||
const finished = common.mustCall();
|
||||
|
||||
Reference in new issue
Block a user