Skip to content

Commit

Permalink
test: add tests for OutgoingMessage setTimeout
Browse files Browse the repository at this point in the history
These tests ensure that OutgoingMessage setTimeout method
will call setTimeout on its socket

Co-authored-by: ZauberNerd <[email protected]>

PR-URL: #24148
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
robin-drexler authored and MylesBorins committed Dec 26, 2018
1 parent abf9bd1 commit 6e8fa53
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/parallel/test-http-outgoing-settimeout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';
const common = require('../common');
const assert = require('assert');

const { OutgoingMessage } = require('http');

{
// tests for settimeout method with socket
const expectedMsecs = 42;
const outgoingMessage = new OutgoingMessage();
outgoingMessage.socket = {
setTimeout: common.mustCall((msecs) => {
assert.strictEqual(msecs, expectedMsecs);
})
};
outgoingMessage.setTimeout(expectedMsecs);
}

{
// tests for settimeout method without socket
const expectedMsecs = 23;
const outgoingMessage = new OutgoingMessage();
outgoingMessage.setTimeout(expectedMsecs);

outgoingMessage.emit('socket', {
setTimeout: common.mustCall((msecs) => {
assert.strictEqual(msecs, expectedMsecs);
})
});
}

0 comments on commit 6e8fa53

Please sign in to comment.