mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
a01c365193
`Client.prototype._addHandle()` in the `_debugger` module has conditions around invalid properties that are not currently tested. This change adds some minimal unit tests. PR-URL: https://github.com/nodejs/node/pull/8518 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const Client = require('_debugger').Client;
|
|
|
|
{
|
|
const client = new Client();
|
|
assert.deepStrictEqual(client.handles, {});
|
|
}
|
|
|
|
{
|
|
const client = new Client();
|
|
client._addHandle(null);
|
|
assert.deepStrictEqual(client.handles, {});
|
|
}
|
|
|
|
{
|
|
const client = new Client();
|
|
client._addHandle('not an object');
|
|
assert.deepStrictEqual(client.handles, {});
|
|
}
|
|
|
|
{
|
|
const client = new Client();
|
|
client._addHandle({ handle: 'not a number' });
|
|
assert.deepStrictEqual(client.handles, {});
|
|
}
|
|
|
|
{
|
|
const client = new Client();
|
|
const validNoScript = { handle: 6, id: 'foo', type: 'not a script' };
|
|
client._addHandle(validNoScript);
|
|
assert.deepStrictEqual(client.handles, { 6: validNoScript });
|
|
assert.deepStrictEqual(client.scripts, {});
|
|
}
|
|
|
|
{
|
|
const client = new Client();
|
|
const validWithScript = { handle: 5, id: 'bar', type: 'script' };
|
|
client._addHandle(validWithScript);
|
|
assert.deepStrictEqual(client.handles, { 5: validWithScript });
|
|
assert.deepStrictEqual(client.scripts, { bar: validWithScript });
|
|
}
|