-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for local audio and video track
- Loading branch information
Showing
7 changed files
with
69 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { createMockedStream } from '../util/test-utils'; | ||
import { LocalAudioTrack } from './local-audio-track'; | ||
import MediaStreamStub from '../mocks/media-stream-stub'; | ||
import { createBrowserMock } from '../mocks/create-browser-mock'; | ||
/** | ||
* A dummy LocalAudioTrack implementation so we can instantiate it for testing. | ||
*/ | ||
class TestLocalAudioTrack extends LocalAudioTrack {} | ||
|
||
describe('LocalAudioTrack', () => { | ||
createBrowserMock(MediaStreamStub, 'MediaStream'); | ||
const mockStream = createMockedStream(); | ||
let localAudioTrack: TestLocalAudioTrack; | ||
beforeEach(() => { | ||
localAudioTrack = new TestLocalAudioTrack(mockStream.getTracks()[0]); | ||
}); | ||
|
||
it('Should call applyConstraints on track when setEncoderConstaints is called', () => { | ||
expect.assertions(2); | ||
const encoderConstraints = { echoCancellation: true, channelCount: 1, sampleSize: 16 }; | ||
|
||
jest.spyOn(localAudioTrack, 'getMediaStreamTrack'); | ||
localAudioTrack.setEncoderConstraints(encoderConstraints); | ||
expect(localAudioTrack.getMediaStreamTrack).toHaveBeenCalledTimes(1); | ||
expect(mockStream.getTracks()[0].applyConstraints).toHaveBeenCalledWith(encoderConstraints); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { createMockedStream } from '../util/test-utils'; | ||
import { LocalVideoTrack } from './local-video-track'; | ||
import MediaStreamStub from '../mocks/media-stream-stub'; | ||
import { createBrowserMock } from '../mocks/create-browser-mock'; | ||
/** | ||
* A dummy LocalVideoTrack implementation so we can instantiate it for testing. | ||
*/ | ||
class TestLocalVideoTrack extends LocalVideoTrack {} | ||
|
||
describe('LocalVideoTrack', () => { | ||
createBrowserMock(MediaStreamStub, 'MediaStream'); | ||
const mockStream = createMockedStream(); | ||
let localVideoTrack: TestLocalVideoTrack; | ||
beforeEach(() => { | ||
localVideoTrack = new TestLocalVideoTrack(mockStream.getTracks()[0]); | ||
}); | ||
|
||
it('Should call applyConstraints on track when setEncoderConstaints is called', () => { | ||
expect.assertions(2); | ||
const encoderConstraints = { frameRate: 30, width: 1920, height: 1080 }; | ||
|
||
jest.spyOn(localVideoTrack, 'getMediaStreamTrack'); | ||
localVideoTrack.setEncoderConstraints(encoderConstraints); | ||
expect(localVideoTrack.getMediaStreamTrack).toHaveBeenCalledTimes(1); | ||
expect(mockStream.getTracks()[0].applyConstraints).toHaveBeenCalledWith(encoderConstraints); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters