Skip to content

Commit

Permalink
test: add coverage for client._addHandle()
Browse files Browse the repository at this point in the history
`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: nodejs#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]>
  • Loading branch information
Trott committed Sep 16, 2016
1 parent ea2a309 commit a01c365
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/parallel/test-debugger-client-addhandle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'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 });
}

0 comments on commit a01c365

Please sign in to comment.