Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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. setReceiverVideoConstraints() {
  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. conference.rtc = rtc;
  49. receiveVideoController = new ReceiveVideoController(conference);
  50. });
  51. describe('when sourceNameSignaling is enabled', () => {
  52. beforeEach(() => {
  53. FeatureFlags.init({ });
  54. });
  55. it('should call setReceiverVideoConstraints with the source names format.', () => {
  56. const rtcSpy = spyOn(rtc, 'setReceiverVideoConstraints');
  57. const constraints = {
  58. onStageSources: [ 'A_camera_1', 'B_screen_2', 'C_camera_1' ],
  59. selectedSources: [ 'A_camera_1' ]
  60. };
  61. receiveVideoController.setReceiverConstraints(constraints);
  62. expect(rtcSpy).toHaveBeenCalledWith(constraints);
  63. });
  64. it('should not allow the endpoints format.', () => {
  65. const constraints = {
  66. onStageEndpoints: [ 'A', 'B', 'C' ],
  67. selectedEndpoints: [ 'A' ]
  68. };
  69. try {
  70. receiveVideoController.setReceiverConstraints(constraints);
  71. fail();
  72. } catch (error) {
  73. expect(error).toEqual(new Error(
  74. '"onStageEndpoints" and "selectedEndpoints" are not supported when sourceNameSignaling is enabled.'
  75. ));
  76. }
  77. });
  78. });
  79. });