mirror of
https://github.com/nodejs/node.git
synced 2025-05-14 21:36:02 +00:00

Add punctuation and comments about code that should not throw. Also remove a obsolete test and refactor some tests. PR-URL: https://github.com/nodejs/node/pull/18669 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
61 lines
1.3 KiB
JavaScript
61 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
common.skipIfInspectorDisabled();
|
|
|
|
const { Session } = require('inspector');
|
|
|
|
const session = new Session();
|
|
|
|
common.expectsError(
|
|
() => session.post('Runtime.evaluate', { expression: '2 + 2' }),
|
|
{
|
|
code: 'ERR_INSPECTOR_NOT_CONNECTED',
|
|
type: Error,
|
|
message: 'Session is not connected'
|
|
}
|
|
);
|
|
|
|
session.connect();
|
|
session.post('Runtime.evaluate', { expression: '2 + 2' });
|
|
|
|
[1, {}, [], true, Infinity, undefined].forEach((i) => {
|
|
common.expectsError(
|
|
() => session.post(i),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message:
|
|
'The "method" argument must be of type string. ' +
|
|
`Received type ${typeof i}`
|
|
}
|
|
);
|
|
});
|
|
|
|
[1, true, Infinity].forEach((i) => {
|
|
common.expectsError(
|
|
() => session.post('test', i),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message:
|
|
'The "params" argument must be of type Object. ' +
|
|
`Received type ${typeof i}`
|
|
}
|
|
);
|
|
});
|
|
|
|
common.expectsError(
|
|
() => session.connect(),
|
|
{
|
|
code: 'ERR_INSPECTOR_ALREADY_CONNECTED',
|
|
type: Error,
|
|
message: 'The inspector is already connected'
|
|
}
|
|
);
|
|
|
|
session.disconnect();
|
|
// Calling disconnect twice should not throw.
|
|
session.disconnect();
|