-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #48717 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
- Loading branch information
1 parent
bf75a11
commit 45c7e5e
Showing
3 changed files
with
51 additions
and
1 deletion.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as common from '../common/index.mjs'; | ||
import assert from 'node:assert'; | ||
import net from 'node:net'; | ||
import { describe, it } from 'node:test'; | ||
|
||
describe('net.Server[Symbol.asyncDispose]()', () => { | ||
it('should close the server', async () => { | ||
const server = net.createServer(); | ||
const timeoutRef = setTimeout(common.mustNotCall(), 2 ** 31 - 1); | ||
|
||
server.listen(0, common.mustCall(async () => { | ||
await server[Symbol.asyncDispose]().then(common.mustCall()); | ||
assert.strictEqual(server.address(), null); | ||
clearTimeout(timeoutRef); | ||
})); | ||
|
||
server.on('close', common.mustCall()); | ||
}); | ||
|
||
it('should resolve even if the server is already closed', async () => { | ||
const server = net.createServer(); | ||
const timeoutRef = setTimeout(common.mustNotCall(), 2 ** 31 - 1); | ||
|
||
server.listen(0, common.mustCall(async () => { | ||
await server[Symbol.asyncDispose]().then(common.mustCall()); | ||
await server[Symbol.asyncDispose]().then(common.mustCall(), common.mustNotCall()); | ||
clearTimeout(timeoutRef); | ||
})); | ||
}); | ||
}); |