1import * as common from '../common/index.mjs'; 2import assert from 'node:assert'; 3import dgram from 'node:dgram'; 4import { describe, it } from 'node:test'; 5 6describe('dgram.Socket[Symbol.asyncDispose]()', () => { 7 it('should close the socket', async () => { 8 const server = dgram.createSocket({ type: 'udp4' }); 9 server.on('close', common.mustCall()); 10 await server[Symbol.asyncDispose]().then(common.mustCall()); 11 12 assert.throws(() => server.address(), { code: 'ERR_SOCKET_DGRAM_NOT_RUNNING' }); 13 }); 14 15 it('should resolve even if the socket is already closed', async () => { 16 const server = dgram.createSocket({ type: 'udp4' }); 17 await server[Symbol.asyncDispose]().then(common.mustCall()); 18 await server[Symbol.asyncDispose]().then(common.mustCall(), common.mustNotCall()); 19 }); 20}); 21