mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
17f6b8c49c
PR-URL: https://github.com/nodejs/node/pull/48717 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
21 lines
809 B
JavaScript
21 lines
809 B
JavaScript
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());
|
|
});
|
|
});
|