Commit 7eed6f4 for jssip.net
commit 7eed6f49a01508161cef0f54c532447fdf71772c
Author: José Luis Millán <jmillan@aliax.net>
Date: Thu Dec 3 12:37:55 2026 +0100
TS: Options
diff --git a/src/Options.js b/src/Options.js
deleted file mode 100644
index ff9be47..0000000
--- a/src/Options.js
+++ /dev/null
@@ -1,253 +0,0 @@
-const EventEmitter = require('events').EventEmitter;
-const { Logger } = require('./Logger');
-const JsSIP_C = require('./Constants');
-const SIPMessage = require('./SIPMessage');
-const Utils = require('./Utils');
-const { RequestSender } = require('./RequestSender');
-const Exceptions = require('./Exceptions');
-
-const logger = new Logger('Options');
-
-module.exports = class Options extends EventEmitter {
- constructor(ua) {
- super();
-
- this._ua = ua;
- this._request = null;
- this._closed = false;
-
- this._direction = null;
- this._local_identity = null;
- this._remote_identity = null;
-
- // Whether an incoming message has been replied.
- this._is_replied = false;
-
- // Custom message empty object for high level use.
- this._data = {};
- }
-
- get direction() {
- return this._direction;
- }
-
- get local_identity() {
- return this._local_identity;
- }
-
- get remote_identity() {
- return this._remote_identity;
- }
-
- send(target, body, options = {}) {
- const originalTarget = target;
-
- if (target === undefined) {
- throw new TypeError('A target is required for OPTIONS');
- }
-
- // Check target validity.
- target = this._ua.normalizeTarget(target);
- if (!target) {
- throw new TypeError(`Invalid target: ${originalTarget}`);
- }
-
- // Get call options.
- const extraHeaders = Utils.cloneArray(options.extraHeaders);
- const eventHandlers = Utils.cloneObject(options.eventHandlers);
- const contentType = options.contentType || 'application/sdp';
-
- // Set event handlers.
- for (const event in eventHandlers) {
- if (Object.prototype.hasOwnProperty.call(eventHandlers, event)) {
- this.on(event, eventHandlers[event]);
- }
- }
-
- extraHeaders.push(`Content-Type: ${contentType}`);
-
- this._request = new SIPMessage.OutgoingRequest(
- JsSIP_C.OPTIONS,
- target,
- this._ua,
- null,
- extraHeaders
- );
-
- if (body) {
- this._request.body = body;
- }
-
- const request_sender = new RequestSender(this._ua, this._request, {
- onRequestTimeout: () => {
- this._onRequestTimeout();
- },
- onTransportError: () => {
- this._onTransportError();
- },
- onReceiveResponse: response => {
- this._receiveResponse(response);
- },
- });
-
- this._newOptions('local', this._request);
-
- request_sender.send();
- }
-
- init_incoming(request) {
- this._request = request;
-
- this._newOptions('remote', request);
-
- // Reply with a 200 OK if the user didn't reply.
- if (!this._is_replied) {
- this._is_replied = true;
- request.reply(200);
- }
-
- this._close();
- }
-
- /**
- * Accept the incoming Options
- * Only valid for incoming Options
- */
- accept(options = {}) {
- const extraHeaders = Utils.cloneArray(options.extraHeaders);
- const body = options.body;
-
- if (this._direction !== 'incoming') {
- throw new Exceptions.NotSupportedError(
- '"accept" not supported for outgoing Options'
- );
- }
-
- if (this._is_replied) {
- throw new Error('incoming Options already replied');
- }
-
- this._is_replied = true;
- this._request.reply(200, null, extraHeaders, body);
- }
-
- /**
- * Reject the incoming Options
- * Only valid for incoming Options
- */
- reject(options = {}) {
- const status_code = options.status_code || 480;
- const reason_phrase = options.reason_phrase;
- const extraHeaders = Utils.cloneArray(options.extraHeaders);
- const body = options.body;
-
- if (this._direction !== 'incoming') {
- throw new Exceptions.NotSupportedError(
- '"reject" not supported for outgoing Options'
- );
- }
-
- if (this._is_replied) {
- throw new Error('incoming Options already replied');
- }
-
- if (status_code < 300 || status_code >= 700) {
- throw new TypeError(`Invalid status_code: ${status_code}`);
- }
-
- this._is_replied = true;
- this._request.reply(status_code, reason_phrase, extraHeaders, body);
- }
-
- _receiveResponse(response) {
- if (this._closed) {
- return;
- }
- switch (true) {
- case /^1[0-9]{2}$/.test(response.status_code): {
- // Ignore provisional responses.
- break;
- }
-
- case /^2[0-9]{2}$/.test(response.status_code): {
- this._succeeded('remote', response);
- break;
- }
-
- default: {
- const cause = Utils.sipErrorCause(response.status_code);
-
- this._failed('remote', response, cause);
- break;
- }
- }
- }
-
- _onRequestTimeout() {
- if (this._closed) {
- return;
- }
- this._failed('system', null, JsSIP_C.causes.REQUEST_TIMEOUT);
- }
-
- _onTransportError() {
- if (this._closed) {
- return;
- }
- this._failed('system', null, JsSIP_C.causes.CONNECTION_ERROR);
- }
-
- _close() {
- this._closed = true;
- this._ua.destroyMessage(this);
- }
-
- /**
- * Internal Callbacks
- */
-
- _newOptions(originator, request) {
- if (originator === 'remote') {
- this._direction = 'incoming';
- this._local_identity = request.to;
- this._remote_identity = request.from;
- } else if (originator === 'local') {
- this._direction = 'outgoing';
- this._local_identity = request.from;
- this._remote_identity = request.to;
- }
-
- this._ua.newOptions(this, {
- originator,
- message: this,
- request,
- });
- }
-
- _failed(originator, response, cause) {
- logger.debug('OPTIONS failed');
-
- this._close();
-
- logger.debug('emit "failed"');
-
- this.emit('failed', {
- originator,
- response: response || null,
- cause,
- });
- }
-
- _succeeded(originator, response) {
- logger.debug('OPTIONS succeeded');
-
- this._close();
-
- logger.debug('emit "succeeded"');
-
- this.emit('succeeded', {
- originator,
- response,
- });
- }
-};
diff --git a/src/Options.ts b/src/Options.ts
new file mode 100644
index 0000000..132f819
--- /dev/null
+++ b/src/Options.ts
@@ -0,0 +1,465 @@
+import { EventEmitter } from 'events';
+
+import * as JsSIP_C from './Constants';
+import type { Direction, Originator } from './Constants';
+import { NotSupportedError } from './Exceptions';
+import { Logger } from './Logger';
+import { RequestSender } from './RequestSender';
+import type { RequestSenderUA } from './RequestSender';
+import * as SIPMessage from './SIPMessage';
+import type { IncomingRequest, IncomingResponse } from './SIPMessage';
+import * as Utils from './Utils';
+import NameAddrHeader = require('./NameAddrHeader');
+import URI = require('./URI');
+
+const logger = new Logger('Options');
+
+/**
+ * Reported when the OPTIONS got a 2xx response.
+ */
+export type OptionsSucceededEvent = {
+ originator: Originator;
+ response: IncomingResponse;
+};
+
+/**
+ * Reported when the OPTIONS could not be answered.
+ */
+export type OptionsFailedEvent = {
+ originator: Originator;
+ response: IncomingResponse | null;
+ cause: JsSIP_C.causes;
+};
+
+/**
+ * The events an {@link Options} emits.
+ */
+export type OptionsEventMap = {
+ succeeded: [event: OptionsSucceededEvent];
+ failed: [event: OptionsFailedEvent];
+};
+
+/**
+ * The listeners the application registers through the `eventHandlers` option
+ * of `send()`.
+ */
+export type OptionsEventHandlers = {
+ [K in keyof OptionsEventMap]: (...args: OptionsEventMap[K]) => void;
+};
+
+/**
+ * Options accepted by `send()`.
+ */
+export type SendOptionsOptions = {
+ /**
+ * Whole `Name: value` header field lines to add to the OPTIONS.
+ */
+ extraHeaders?: string[] | null;
+ /**
+ * Value of the Content-Type header field.
+ *
+ * @defaultValue `'application/sdp'`
+ */
+ contentType?: string;
+ /**
+ * Listeners registered before the OPTIONS is sent, so that no event is
+ * missed.
+ */
+ eventHandlers?: Partial<OptionsEventHandlers> | null;
+};
+
+/**
+ * Options accepted by `accept()`.
+ */
+export type AcceptOptions = {
+ extraHeaders?: string[] | null;
+ body?: string;
+};
+
+/**
+ * Options accepted by `reject()`.
+ */
+export type RejectOptions = {
+ extraHeaders?: string[] | null;
+ body?: string;
+ /**
+ * Status code of the response, between 300 and 699.
+ *
+ * @defaultValue `480`
+ */
+ status_code?: number;
+ /**
+ * Reason phrase of the response.
+ */
+ reason_phrase?: string;
+};
+
+/**
+ * The `UA` surface an OPTIONS applicant depends on.
+ *
+ * TODO: Replace with `import type { UA } from './UA'` once `UA` is ported to
+ * TypeScript.
+ */
+export interface OptionsUA extends RequestSenderUA {
+ normalizeTarget(target: string | URI): URI | undefined;
+
+ newOptions(
+ options: Options,
+ data: {
+ originator: Originator;
+ message: Options;
+ request: SIPMessage.OutgoingRequest | IncomingRequest;
+ }
+ ): void;
+
+ destroyOptions(options: Options): void;
+}
+
+/**
+ * SIP OPTIONS capabilities querying.
+ *
+ * @example
+ * ```ts
+ * ua.sendOptions('sip:bob@example.com', undefined, {
+ * eventHandlers: {
+ * succeeded: ({ response }) => console.log(response.getHeader('Allow')),
+ * failed: ({ cause }) => console.log('not answered', cause),
+ * },
+ * });
+ * ```
+ */
+export class Options extends EventEmitter<OptionsEventMap> {
+ #ua: OptionsUA;
+ #request: SIPMessage.OutgoingRequest | IncomingRequest | null;
+ #closed: boolean;
+ #direction: Direction | null;
+ #local_identity: NameAddrHeader | null;
+ #remote_identity: NameAddrHeader | null;
+
+ // Whether an incoming OPTIONS has been replied.
+ #is_replied: boolean;
+
+ // Custom object for high level use.
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ #data: any;
+
+ constructor(ua: OptionsUA) {
+ super();
+
+ this.#ua = ua;
+ this.#request = null;
+ this.#closed = false;
+
+ this.#direction = null;
+ this.#local_identity = null;
+ this.#remote_identity = null;
+
+ this.#is_replied = false;
+
+ this.#data = {};
+ }
+
+ /**
+ * Who sent the OPTIONS: `outgoing` when the local user did, `incoming`
+ * when the remote peer did.
+ */
+ get direction(): Direction | null {
+ return this.#direction;
+ }
+
+ /**
+ * Custom object for high level use, empty to begin with.
+ */
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ get data(): any {
+ return this.#data;
+ }
+
+ /**
+ * Set the custom object for high level use.
+ */
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ set data(data: any) {
+ this.#data = data;
+ }
+
+ /**
+ * Local identity. The From header field value when the direction is
+ * `outgoing`, the To header field value when it is `incoming`.
+ */
+ get local_identity(): NameAddrHeader | null {
+ return this.#local_identity;
+ }
+
+ /**
+ * Remote identity. The To header field value when the direction is
+ * `outgoing`, the From header field value when it is `incoming`.
+ */
+ get remote_identity(): NameAddrHeader | null {
+ return this.#remote_identity;
+ }
+
+ /**
+ * Send an OPTIONS request to the given target.
+ *
+ * @param target - Address of the remote peer.
+ * @param body - Content of the request, if any.
+ *
+ * @throws
+ * - `TypeError` if `target` is not given, or if it cannot be turned into a
+ * valid SIP URI.
+ */
+ send(
+ target: string | URI,
+ body?: string,
+ options: SendOptionsOptions = {}
+ ): void {
+ const originalTarget = target;
+
+ if (target === undefined) {
+ throw new TypeError('A target is required for OPTIONS');
+ }
+
+ // Check target validity.
+ const uri = this.#ua.normalizeTarget(target);
+
+ if (!uri) {
+ throw new TypeError(`Invalid target: ${originalTarget.toString()}`);
+ }
+
+ // Get call options.
+ const extraHeaders = Utils.cloneArray(options.extraHeaders);
+ const eventHandlers = Utils.cloneObject(options.eventHandlers);
+ const contentType = options.contentType || 'application/sdp';
+
+ // Set event handlers. They are registered one by one, rather than by
+ // iterating the object, so that each listener keeps the signature of the
+ // event it is registered for.
+ if (eventHandlers.succeeded) {
+ this.on('succeeded', eventHandlers.succeeded);
+ }
+
+ if (eventHandlers.failed) {
+ this.on('failed', eventHandlers.failed);
+ }
+
+ extraHeaders.push(`Content-Type: ${contentType}`);
+
+ const request = new SIPMessage.OutgoingRequest(
+ JsSIP_C.OPTIONS,
+ uri,
+ this.#ua,
+ null,
+ extraHeaders
+ );
+
+ this.#request = request;
+
+ if (body) {
+ request.body = body;
+ }
+
+ const request_sender = new RequestSender(this.#ua, request, {
+ onRequestTimeout: () => {
+ this.#onRequestTimeout();
+ },
+ onTransportError: () => {
+ this.#onTransportError();
+ },
+ onReceiveResponse: response => {
+ this.#receiveResponse(response);
+ },
+ });
+
+ this.#newOptions('local', request);
+
+ request_sender.send();
+ }
+
+ /**
+ * Take over a received OPTIONS request.
+ *
+ * @remarks
+ * - Called by the `UA`. The application must not call it.
+ */
+ init_incoming(request: IncomingRequest): void {
+ this.#request = request;
+
+ this.#newOptions('remote', request);
+
+ // Reply with a 200 OK if the user didn't reply.
+ if (!this.#is_replied) {
+ this.#is_replied = true;
+ request.reply(200);
+ }
+
+ this.#close();
+ }
+
+ /**
+ * Accept the incoming OPTIONS, answering it with a 200.
+ *
+ * @throws
+ * - {@link NotSupportedError} if the OPTIONS is outgoing.
+ * - `Error` if the OPTIONS was already replied.
+ */
+ accept(options: AcceptOptions = {}): void {
+ const extraHeaders = Utils.cloneArray(options.extraHeaders);
+ const body = options.body;
+
+ if (this.#direction !== 'incoming') {
+ throw new NotSupportedError(
+ '"accept" not supported for outgoing Options'
+ );
+ }
+
+ if (this.#is_replied) {
+ throw new Error('incoming Options already replied');
+ }
+
+ this.#is_replied = true;
+ this.#incomingRequest().reply(200, null, extraHeaders, body);
+ }
+
+ /**
+ * Reject the incoming OPTIONS.
+ *
+ * @throws
+ * - {@link NotSupportedError} if the OPTIONS is outgoing.
+ * - `Error` if the OPTIONS was already replied.
+ * - `TypeError` if `status_code` is not between 300 and 699.
+ */
+ reject(options: RejectOptions = {}): void {
+ const status_code = options.status_code || 480;
+ const reason_phrase = options.reason_phrase;
+ const extraHeaders = Utils.cloneArray(options.extraHeaders);
+ const body = options.body;
+
+ if (this.#direction !== 'incoming') {
+ throw new NotSupportedError(
+ '"reject" not supported for outgoing Options'
+ );
+ }
+
+ if (this.#is_replied) {
+ throw new Error('incoming Options already replied');
+ }
+
+ if (status_code < 300 || status_code >= 700) {
+ throw new TypeError(`Invalid status_code: ${status_code}`);
+ }
+
+ this.#is_replied = true;
+ this.#incomingRequest().reply(
+ status_code,
+ reason_phrase,
+ extraHeaders,
+ body
+ );
+ }
+
+ /**
+ * The received request, which `accept()` and `reject()` reply to once they
+ * have checked that the OPTIONS is an incoming one.
+ */
+ #incomingRequest(): IncomingRequest {
+ return this.#request as IncomingRequest;
+ }
+
+ #receiveResponse(response: IncomingResponse): void {
+ if (this.#closed) {
+ return;
+ }
+ switch (true) {
+ case /^1[0-9]{2}$/.test(String(response.status_code)): {
+ // Ignore provisional responses.
+ break;
+ }
+
+ case /^2[0-9]{2}$/.test(String(response.status_code)): {
+ this.#succeeded('remote', response);
+ break;
+ }
+
+ default: {
+ const cause = Utils.sipErrorCause(response.status_code);
+
+ this.#failed('remote', response, cause);
+ break;
+ }
+ }
+ }
+
+ #onRequestTimeout(): void {
+ if (this.#closed) {
+ return;
+ }
+ this.#failed('system', null, JsSIP_C.causes.REQUEST_TIMEOUT);
+ }
+
+ #onTransportError(): void {
+ if (this.#closed) {
+ return;
+ }
+ this.#failed('system', null, JsSIP_C.causes.CONNECTION_ERROR);
+ }
+
+ #close(): void {
+ this.#closed = true;
+ this.#ua.destroyOptions(this);
+ }
+
+ // Internal callbacks.
+
+ #newOptions(
+ originator: Originator,
+ request: SIPMessage.OutgoingRequest | IncomingRequest
+ ): void {
+ if (originator === 'remote') {
+ this.#direction = 'incoming';
+ this.#local_identity = request.to;
+ this.#remote_identity = request.from;
+ } else if (originator === 'local') {
+ this.#direction = 'outgoing';
+ this.#local_identity = request.from;
+ this.#remote_identity = request.to;
+ }
+
+ this.#ua.newOptions(this, {
+ originator,
+ message: this,
+ request,
+ });
+ }
+
+ #failed(
+ originator: Originator,
+ response: IncomingResponse | null,
+ cause: JsSIP_C.causes
+ ): void {
+ logger.debug('OPTIONS failed');
+
+ this.#close();
+
+ logger.debug('emit "failed"');
+
+ this.emit('failed', {
+ originator,
+ response: response || null,
+ cause,
+ });
+ }
+
+ #succeeded(originator: Originator, response: IncomingResponse): void {
+ logger.debug('OPTIONS succeeded');
+
+ this.#close();
+
+ logger.debug('emit "succeeded"');
+
+ this.emit('succeeded', {
+ originator,
+ response,
+ });
+ }
+}
diff --git a/src/UA.d.ts b/src/UA.d.ts
index 16c0f3f..9254189 100644
--- a/src/UA.d.ts
+++ b/src/UA.d.ts
@@ -14,6 +14,7 @@ import {
OutgoingRequest,
} from './SIPMessage';
import { Message, SendMessageOptions } from './Message';
+import { Options, SendOptionsOptions } from './Options';
import { Registrator } from './Registrator';
import { Notifier } from './Notifier';
import { Subscriber } from './Subscriber';
@@ -120,11 +121,13 @@ export interface OutgoingMessageEvent {
export interface IncomingOptionsEvent {
originator: Originator.REMOTE;
+ message: Options;
request: IncomingRequest;
}
export interface OutgoingOptionsEvent {
originator: Originator.LOCAL;
+ message: Options;
request: OutgoingRequest;
}
@@ -269,6 +272,12 @@ export class UA extends EventEmitter {
options?: SendMessageOptions
): Message;
+ sendOptions(
+ target: string | URI,
+ body?: string,
+ options?: SendOptionsOptions
+ ): Options;
+
subscribe(
target: string,
eventName: string,
diff --git a/src/UA.js b/src/UA.js
index 1eeb728..5049dd3 100644
--- a/src/UA.js
+++ b/src/UA.js
@@ -8,7 +8,7 @@ const RTCSession = require('./RTCSession');
const Subscriber = require('./Subscriber');
const Notifier = require('./Notifier');
const { Message } = require('./Message');
-const Options = require('./Options');
+const { Options } = require('./Options');
const Transactions = require('./Transactions');
const { Transport } = require('./Transport');
const Utils = require('./Utils');
@@ -516,6 +516,13 @@ module.exports = class UA extends EventEmitter {
delete this._applicants[message];
}
+ /**
+ * Options destroyed.
+ */
+ destroyOptions(options) {
+ delete this._applicants[options];
+ }
+
/**
* Subscriber sent its initial SUBSCRIBE.
*/
diff --git a/src/test/test-Options.ts b/src/test/test-Options.ts
new file mode 100644
index 0000000..765372e
--- /dev/null
+++ b/src/test/test-Options.ts
@@ -0,0 +1,151 @@
+import { setTimeout as delay } from 'timers/promises';
+
+import './include/common';
+import { buildRequest, buildResponse, method } from './include/sipMessage';
+import TestSocket from './include/TestSocket';
+import { startUA, stopUA } from './include/ua';
+
+import { UA } from '../JsSIP';
+import type { IncomingOptionsEvent } from '../UA';
+
+const AOR = 'sip:alice@example.com';
+const REMOTE = 'sip:bob@example.com';
+
+// Answers every OPTIONS with the given status code.
+class OptionsSocket extends TestSocket {
+ constructor(private readonly status: number = 200) {
+ super();
+ }
+
+ protected override onRequest(request: string): void {
+ if (method(request) !== 'OPTIONS') {
+ return;
+ }
+
+ this.receive(buildResponse(request, this.status, { toTag: 'remotetag' }));
+ }
+}
+
+/**
+ * The applicants the UA is holding on to. They are the `Message` and
+ * `Options` instances that have not been destroyed yet.
+ *
+ * NOTE: Reaches into the UA because there is no public way to observe them.
+ */
+function applicants(ua: UA): unknown[] {
+ return Object.values(
+ (ua as unknown as { _applicants: Record<string, unknown> })._applicants
+ );
+}
+
+describe('UA.destroyOptions()', () => {
+ test('an answered outgoing OPTIONS is destroyed', async () => {
+ const socket = new OptionsSocket();
+ const ua = new UA({ sockets: socket, uri: AOR, register: false });
+
+ await startUA(ua);
+
+ let succeeded = false;
+
+ ua.sendOptions(REMOTE, undefined, {
+ eventHandlers: { succeeded: () => (succeeded = true) },
+ });
+
+ // The OPTIONS is in flight, so the UA is holding its applicant.
+ expect(applicants(ua)).toHaveLength(1);
+
+ await delay(50);
+
+ expect(succeeded).toBe(true);
+ expect(applicants(ua)).toHaveLength(0);
+
+ await stopUA(ua);
+ });
+
+ test('a rejected outgoing OPTIONS is destroyed too', async () => {
+ const socket = new OptionsSocket(486);
+ const ua = new UA({ sockets: socket, uri: AOR, register: false });
+
+ await startUA(ua);
+
+ let failed = false;
+
+ ua.sendOptions(REMOTE, undefined, {
+ eventHandlers: { failed: () => (failed = true) },
+ });
+
+ await delay(50);
+
+ expect(failed).toBe(true);
+ expect(applicants(ua)).toHaveLength(0);
+
+ await stopUA(ua);
+ });
+
+ test('an accepted incoming OPTIONS is destroyed', async () => {
+ const socket = new OptionsSocket();
+ const ua = new UA({ sockets: socket, uri: AOR, register: false });
+
+ await startUA(ua);
+
+ let held: unknown[] = [];
+
+ // Without a 'newOptions' listener the UA answers the request itself and
+ // never builds an Options, so there would be nothing to destroy.
+ ua.on('newOptions', ({ message }: IncomingOptionsEvent) => {
+ // The OPTIONS is being handled, so the UA is holding its applicant.
+ held = applicants(ua);
+
+ message.accept();
+ });
+
+ socket.receive(
+ buildRequest('OPTIONS', AOR, {
+ from: `<${REMOTE}>;tag=remotetag`,
+ to: `<${AOR}>`,
+ callId: 'the-call-id',
+ cseq: 1,
+ })
+ );
+
+ await delay(50);
+
+ expect(held).toHaveLength(1);
+ expect(socket.statusFor('the-call-id')).toBe(200);
+ expect(applicants(ua)).toHaveLength(0);
+
+ await stopUA(ua);
+ });
+
+ test('an incoming OPTIONS the application ignores is destroyed too', async () => {
+ const socket = new OptionsSocket();
+ const ua = new UA({ sockets: socket, uri: AOR, register: false });
+
+ await startUA(ua);
+
+ let held: unknown[] = [];
+
+ // The listener does not reply, so init_incoming() answers with a 200 on
+ // its way out and destroys the Options all the same.
+ ua.on('newOptions', () => {
+ held = applicants(ua);
+ });
+
+ socket.receive(
+ buildRequest('OPTIONS', AOR, {
+ from: `<${REMOTE}>;tag=remotetag`,
+ to: `<${AOR}>`,
+ callId: 'the-call-id',
+ cseq: 1,
+ })
+ );
+
+ await delay(50);
+
+ expect(held).toHaveLength(1);
+ expect(socket.statusFor('the-call-id')).toBe(200);
+ expect(applicants(ua)).toHaveLength(0);
+
+ await stopUA(ua);
+ });
+});