Skip to content

Commit 9ffb2f3

Browse files
TrottMylesBorins
authored andcommitted
test: add coverage for client._addHandle()
`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: #8518 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 8da2dcb commit 9ffb2f3

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
const Client = require('_debugger').Client;
6+
7+
{
8+
const client = new Client();
9+
assert.deepStrictEqual(client.handles, {});
10+
}
11+
12+
{
13+
const client = new Client();
14+
client._addHandle(null);
15+
assert.deepStrictEqual(client.handles, {});
16+
}
17+
18+
{
19+
const client = new Client();
20+
client._addHandle('not an object');
21+
assert.deepStrictEqual(client.handles, {});
22+
}
23+
24+
{
25+
const client = new Client();
26+
client._addHandle({ handle: 'not a number' });
27+
assert.deepStrictEqual(client.handles, {});
28+
}
29+
30+
{
31+
const client = new Client();
32+
const validNoScript = { handle: 6, id: 'foo', type: 'not a script' };
33+
client._addHandle(validNoScript);
34+
assert.deepStrictEqual(client.handles, { 6: validNoScript });
35+
assert.deepStrictEqual(client.scripts, {});
36+
}
37+
38+
{
39+
const client = new Client();
40+
const validWithScript = { handle: 5, id: 'bar', type: 'script' };
41+
client._addHandle(validWithScript);
42+
assert.deepStrictEqual(client.handles, { 5: validWithScript });
43+
assert.deepStrictEqual(client.scripts, { bar: validWithScript });
44+
}

0 commit comments

Comments
 (0)