Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

ReceiveVideoController.spec.js 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import FeatureFlags from '../flags/FeatureFlags';
  2. import Listenable from '../util/Listenable';
  3. import ReceiveVideoController from './ReceiveVideoController';
  4. // JSDocs disabled for Mock classes to avoid duplication - check on the original classes for info.
  5. /* eslint-disable require-jsdoc */
  6. /**
  7. * Mock conference for the purpose of this test file.
  8. */
  9. class MockConference extends Listenable {
  10. /**
  11. * A constructor...
  12. */
  13. constructor() {
  14. super();
  15. this.options = {
  16. config: {}
  17. };
  18. this.activeMediaSession = undefined;
  19. this.mediaSessions = [];
  20. }
  21. getMediaSessions() {
  22. return this.mediaSessions;
  23. }
  24. }
  25. /**
  26. * Mock {@link RTC} - add things as needed, but only things useful for all tests.
  27. */
  28. export class MockRTC extends Listenable {
  29. /**
  30. * constructor
  31. */
  32. /* eslint-disable no-useless-constructor */
  33. constructor() {
  34. super();
  35. }
  36. // eslint-disable-next-line no-empty-function
  37. setNewReceiverVideoConstraints() {
  38. }
  39. }
  40. /* eslint-enable require-jsdoc */
  41. describe('ReceiveVideoController', () => {
  42. let conference;
  43. let rtc;
  44. let receiveVideoController;
  45. beforeEach(() => {
  46. conference = new MockConference();
  47. rtc = new MockRTC();
  48. receiveVideoController = new ReceiveVideoController(conference, rtc);
  49. });
  50. describe('when sourceNameSignaling is enabled', () => {
  51. beforeEach(() => {
  52. FeatureFlags.init({ sourceNameSignaling: true });
  53. });
  54. it('should call setNewReceiverVideoConstraints with the source names format.', () => {
  55. const rtcSpy = spyOn(rtc, 'setNewReceiverVideoConstraints');
  56. const constraints = {
  57. onStageSources: [ 'A_camera_1', 'B_screen_2', 'C_camera_1' ],
  58. selectedSources: [ 'A_camera_1' ]
  59. };
  60. receiveVideoController.setReceiverConstraints(constraints);
  61. expect(rtcSpy).toHaveBeenCalledWith(constraints);
  62. });
  63. it('should not allow the endpoints format.', () => {
  64. const constraints = {
  65. onStageEndpoints: [ 'A', 'B', 'C' ],
  66. selectedEndpoints: [ 'A' ]
  67. };
  68. try {
  69. receiveVideoController.setReceiverConstraints(constraints);
  70. fail();
  71. } catch (error) {
  72. expect(error).toEqual(new Error(
  73. '"onStageEndpoints" and "selectedEndpoints" are not supported when sourceNameSignaling is enabled.'
  74. ));
  75. }
  76. });
  77. });
  78. });