forked from jitsi/lib-jitsi-meet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
JitsiMeetJS.spec.ts
39 lines (33 loc) · 1.45 KB
/
JitsiMeetJS.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import JitsiMeetJS from './JitsiMeetJS';
import { VideoType } from './service/RTC/VideoType';
import { MediaType } from './service/RTC/MediaType';
import { JitsiTrackErrors } from './JitsiTrackErrors';
describe('JitsiMeetJS', () => {
describe('createLocalTracksFromMediaStreams', () => {
it('creates a local track from a media stream', () => {
const canvas = document.createElement('canvas');
const canvasStream = canvas.captureStream(5);
const trackInfo = {
stream: canvasStream,
sourceType: 'canvas',
mediaType: MediaType.VIDEO,
videoType: VideoType.DESKTOP
};
const newTracks = JitsiMeetJS.createLocalTracksFromMediaStreams([ trackInfo ]);
expect(newTracks).toBeDefined();
expect(newTracks.length).toBe(1);
});
it('throws an error if track is not the correct media type', () => {
const canvas = document.createElement('canvas');
const canvasStream = canvas.captureStream(5);
const trackInfo = {
stream: canvasStream,
sourceType: 'canvas',
mediaType: MediaType.AUDIO,
videoType: VideoType.DESKTOP
};
expect(() => JitsiMeetJS.createLocalTracksFromMediaStreams([ trackInfo ]))
.toThrowError(JitsiTrackErrors.TRACK_NO_STREAM_TRACKS_FOUND);
});
});
});