From 154d6893b0d3bc904418890d2584618e5afbfb6b Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 8 Sep 2016 15:42:33 -0700 Subject: [PATCH] test: add test-debug-protocol-execute 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: https://github.com/nodejs/node/pull/8454 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- test/parallel/test-debug-protocol-execute.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/parallel/test-debug-protocol-execute.js diff --git a/test/parallel/test-debug-protocol-execute.js b/test/parallel/test-debug-protocol-execute.js new file mode 100644 index 00000000000000..e87b25f5cb45da --- /dev/null +++ b/test/parallel/test-debug-protocol-execute.js @@ -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$/ +);