Skip to content

Commit d2ff9fa

Browse files
author
Andrew Kuzmenko
committed
test: fix eslint and use common module for expectsError
Fix 'max-len','no-restricted-syntax' (assert.throws must be envoken with at least two args) and useless blank lines at the end of file
1 parent 3735341 commit d2ff9fa

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

test/parallel/test-vm-module-basic.js

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44

55
const common = require('../common');
66
const assert = require('assert');
7-
const { Module, SourceTextModule, SyntheticModule, createContext } = require('vm');
7+
const {
8+
Module,
9+
SourceTextModule,
10+
SyntheticModule,
11+
createContext
12+
} = require('vm');
813
const util = require('util');
914

1015
(async function test1() {
@@ -110,39 +115,35 @@ const util = require('util');
110115

111116
// Check the impossibility of creating an abstract instance of the Module.
112117
{
113-
assert.throws(
114-
() => {
115-
new Module();
116-
},
117-
/^TypeError: Module is not a constructor$/
118-
);
119-
118+
common.expectsError(() => new Module(), {
119+
message: 'Module is not a constructor',
120+
type: TypeError
121+
});
120122
}
121123

122124
// Check to throws invalid exportNames
123125
{
124-
assert.throws(
125-
() => {
126-
new SyntheticModule(undefined, () => {}, {});
127-
},
128-
);
126+
common.expectsError(() => new SyntheticModule(undefined, () => {}, {}), {
127+
message: 'The "exportNames" argument must be an Array of strings.' +
128+
' Received undefined',
129+
type: TypeError
130+
});
129131
}
130132

131133
// Check to throws invalid evaluateCallback
132134
{
133-
assert.throws(
134-
() => {
135-
new SyntheticModule([], undefined, {});
136-
},
137-
);
135+
common.expectsError(() => new SyntheticModule([], undefined, {}), {
136+
message: 'The "evaluateCallback" argument must be of type function.' +
137+
' Received undefined',
138+
type: TypeError
139+
});
138140
}
139141

140142
// Check to throws invalid options
141143
{
142-
assert.throws(
143-
() => {
144-
new SyntheticModule([], () => {}, null);
145-
},
146-
);
144+
common.expectsError(() => new SyntheticModule([], () => {}, null), {
145+
message: 'The "options" argument must be of type object.' +
146+
' Received null',
147+
type: TypeError
148+
});
147149
}
148-

0 commit comments

Comments
 (0)