From 5a6df6449054fe603969ca9c43ac9da1fa8cb5fb Mon Sep 17 00:00:00 2001 From: Pankaj Kumar Bind Date: Mon, 30 Jun 2025 19:36:33 +0530 Subject: [PATCH] feat: Add TypeScript definition tests for Tracks and LocalTrackOptions --- tsdef/twilio-video-tests.ts | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/tsdef/twilio-video-tests.ts b/tsdef/twilio-video-tests.ts index 9d1f0ce68..5da107e20 100644 --- a/tsdef/twilio-video-tests.ts +++ b/tsdef/twilio-video-tests.ts @@ -419,14 +419,13 @@ function trackSubscribed(track: Video.VideoTrack | Video.AudioTrack) { function trackUnsubscribed(track: Video.VideoTrack | Video.AudioTrack) { const element = document.createElement(track.kind); - track.detach('#foo').remove(); - track.detach(element).remove(); - track.detach().forEach(element => element.remove()); + track.detach('#foo'); + track.detach(element); + track.detach().forEach(el => el.remove()); } function insertDomElement(element: HTMLMediaElement) { - document.createElement('div'); - element.appendChild(element); + document.createElement('div').appendChild(element); } function useConnectionOptions() { @@ -508,3 +507,31 @@ initRoom(); unpublishTracks(); runPreflight(); mediaWarnings(); + +// New test cases for AudioTrack, VideoTrack, and LocalTrackOptions + +const localTrackOptions: Video.LocalTrackOptions = { + logLevel: 'info', + name: 'my-track' +}; + +const audioTrack: Video.AudioTrack = new Video.AudioTrack(); +const videoTrack: Video.VideoTrack = new Video.VideoTrack(); + +// Test AudioTrack attach method +const audioElement: HTMLAudioElement = audioTrack.attach(); +audioTrack.attach(document.createElement('audio')); + +// Test VideoTrack attach method +const videoElement: HTMLVideoElement = videoTrack.attach() as HTMLVideoElement; +videoTrack.attach(document.createElement('video')); + +// Test createLocalAudioTrack +Video.createLocalAudioTrack(localTrackOptions).then((localAudioTrack: Video.LocalAudioTrack) => { + const mediaStreamTrack: MediaStreamTrack = localAudioTrack.mediaStreamTrack; +}); + +// Test createLocalVideoTrack +Video.createLocalVideoTrack(localTrackOptions).then((localVideoTrack: Video.LocalVideoTrack) => { + const mediaStreamTrack: MediaStreamTrack = localVideoTrack.mediaStreamTrack; +}); \ No newline at end of file