Skip to content

Commit

Permalink
test: add test-debug-protocol-execute
Browse files Browse the repository at this point in the history
Add test for `Protocol` object in `_debugger` module. This test covers
some edge cases that fill some coverage gaps in our testing (such as the
"Unknown state" error).

PR-URL: #8454
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott authored and MylesBorins committed Oct 26, 2016
1 parent a3d0802 commit 775c84e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/parallel/test-debug-protocol-execute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

require('../common');
const assert = require('assert');
const debug = require('_debugger');

const protocol = new debug.Protocol();

assert.strictEqual(protocol.state, 'headers');

protocol.execute('Content-Length: 10\r\n\r\nfhqwhgads');

assert.strictEqual(protocol.state, 'body');
assert.strictEqual(protocol.res.body, undefined);

protocol.state = 'sterrance';
assert.throws(
() => { protocol.execute('grumblecakes'); },
/^Error: Unknown state$/
);

0 comments on commit 775c84e

Please sign in to comment.