Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
test: add tests for OutgoingMessage setTimeout
These tests ensure that OutgoingMessage setTimeout method will call setTimeout on its socket Co-authored-by: ZauberNerd <zaubernerd@zaubernerd.de> PR-URL: #24148 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- Loading branch information
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @@ -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); | ||
| }) | ||
| }); | ||
| } |