-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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 <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
- Loading branch information
1 parent
f74c2fc
commit 573eb4b
Showing
3 changed files
with
41 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,20 @@ | ||
import * as common from '../common/index.mjs'; | ||
import assert from 'node:assert'; | ||
import dgram from 'node:dgram'; | ||
import { describe, it } from 'node:test'; | ||
|
||
describe('dgram.Socket[Symbol.asyncDispose]()', () => { | ||
it('should close the socket', async () => { | ||
const server = dgram.createSocket({ type: 'udp4' }); | ||
server.on('close', common.mustCall()); | ||
await server[Symbol.asyncDispose]().then(common.mustCall()); | ||
|
||
assert.throws(() => server.address(), { code: 'ERR_SOCKET_DGRAM_NOT_RUNNING' }); | ||
}); | ||
|
||
it('should resolve even if the socket is already closed', async () => { | ||
const server = dgram.createSocket({ type: 'udp4' }); | ||
await server[Symbol.asyncDispose]().then(common.mustCall()); | ||
await server[Symbol.asyncDispose]().then(common.mustCall(), common.mustNotCall()); | ||
}); | ||
}); |