Skip to content

Commit

Permalink
test: fix eslint and use common module for expectsError
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Andrew Kuzmenko committed Dec 20, 2019
1 parent 3735341 commit d2ff9fa
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions test/parallel/test-vm-module-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

const common = require('../common');
const assert = require('assert');
const { Module, SourceTextModule, SyntheticModule, createContext } = require('vm');
const {
Module,
SourceTextModule,
SyntheticModule,
createContext
} = require('vm');
const util = require('util');

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

// Check the impossibility of creating an abstract instance of the Module.
{
assert.throws(
() => {
new Module();
},
/^TypeError: Module is not a constructor$/
);

common.expectsError(() => new Module(), {
message: 'Module is not a constructor',
type: TypeError
});
}

// Check to throws invalid exportNames
{
assert.throws(
() => {
new SyntheticModule(undefined, () => {}, {});
},
);
common.expectsError(() => new SyntheticModule(undefined, () => {}, {}), {
message: 'The "exportNames" argument must be an Array of strings.' +
' Received undefined',
type: TypeError
});
}

// Check to throws invalid evaluateCallback
{
assert.throws(
() => {
new SyntheticModule([], undefined, {});
},
);
common.expectsError(() => new SyntheticModule([], undefined, {}), {
message: 'The "evaluateCallback" argument must be of type function.' +
' Received undefined',
type: TypeError
});
}

// Check to throws invalid options
{
assert.throws(
() => {
new SyntheticModule([], () => {}, null);
},
);
common.expectsError(() => new SyntheticModule([], () => {}, null), {
message: 'The "options" argument must be of type object.' +
' Received null',
type: TypeError
});
}

0 comments on commit d2ff9fa

Please sign in to comment.