diff --git a/src/lib/viewers/media/MP4Controls.scss b/src/lib/viewers/media/MP4Controls.scss index 24a353fb1..69c94d624 100644 --- a/src/lib/viewers/media/MP4Controls.scss +++ b/src/lib/viewers/media/MP4Controls.scss @@ -1,4 +1,4 @@ -@import '../controls//media/styles'; +@import '../controls/media/styles'; .bp-MP4Controls { @include bp-VideoControls; diff --git a/src/lib/viewers/media/__tests__/DashControls-test.tsx b/src/lib/viewers/media/__tests__/DashControls-test.tsx new file mode 100644 index 000000000..a02134b95 --- /dev/null +++ b/src/lib/viewers/media/__tests__/DashControls-test.tsx @@ -0,0 +1,44 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import DashControls from '../DashControls'; +import MediaFullscreenToggle from '../../controls/media/MediaFullscreenToggle'; +import MediaSettings from '../../controls/media/MediaSettings'; +import PlayPauseToggle from '../../controls/media/PlayPauseToggle'; +import TimeControls from '../../controls/media/TimeControls'; +import VolumeControls from '../../controls/media/VolumeControls'; + +describe('DashControls', () => { + describe('render', () => { + test('should return a valid wrapper', () => { + const onAutoplayChange = jest.fn(); + const onFullscreenToggle = jest.fn(); + const onMuteChange = jest.fn(); + const onRateChange = jest.fn(); + const onPlayPause = jest.fn(); + const onTimeChange = jest.fn(); + const onVolumeChange = jest.fn(); + const wrapper = shallow( + , + ); + + expect(wrapper.hasClass('bp-DashControls')).toBe(true); + expect(wrapper.find(MediaFullscreenToggle).prop('onFullscreenToggle')).toEqual(onFullscreenToggle); + expect(wrapper.find(MediaSettings).prop('onAutoplayChange')).toEqual(onAutoplayChange); + expect(wrapper.find(MediaSettings).prop('onRateChange')).toEqual(onRateChange); + expect(wrapper.find(PlayPauseToggle).prop('onPlayPause')).toEqual(onPlayPause); + expect(wrapper.find(TimeControls).prop('onTimeChange')).toEqual(onTimeChange); + expect(wrapper.find(VolumeControls).prop('onMuteChange')).toEqual(onMuteChange); + expect(wrapper.find(VolumeControls).prop('onVolumeChange')).toEqual(onVolumeChange); + }); + }); +}); diff --git a/src/lib/viewers/media/__tests__/DashViewer-test.js b/src/lib/viewers/media/__tests__/DashViewer-test.js index e2c3bba67..e45aec57f 100644 --- a/src/lib/viewers/media/__tests__/DashViewer-test.js +++ b/src/lib/viewers/media/__tests__/DashViewer-test.js @@ -665,6 +665,29 @@ describe('lib/viewers/media/DashViewer', () => { expect(dash.mediaControls.show).toBeCalled(); expect(dash.loadUI).toBeCalled(); }); + + describe('With react controls', () => { + beforeEach(() => { + jest.spyOn(dash, 'calculateVideoDimensions').mockImplementation(); + jest.spyOn(dash, 'getViewerOption').mockImplementation(() => true); + jest.spyOn(dash, 'loadAlternateAudio').mockImplementation(); + jest.spyOn(dash, 'loadFilmStrip').mockImplementation(); + jest.spyOn(dash, 'loadSubtitles').mockImplementation(); + jest.spyOn(dash, 'loadUIReact').mockImplementation(); + jest.spyOn(dash, 'loadUI').mockImplementation(); + jest.spyOn(dash, 'resize').mockImplementation(); + }); + + test('should call loadUIReact', () => { + dash.loadeddataHandler(); + + expect(dash.loadUIReact).toBeCalled(); + expect(dash.loadUI).not.toBeCalled(); + expect(dash.loadFilmStrip).not.toBeCalled(); + expect(dash.loadSubtitles).not.toBeCalled(); + expect(dash.loadAlternateAudio).not.toBeCalled(); + }); + }); }); describe('loadUI()', () => { @@ -1442,4 +1465,35 @@ describe('lib/viewers/media/DashViewer', () => { expect(dash.determineWatchLength()).toBe(10000); }); }); + + describe('renderUI()', () => { + const getProps = instance => instance.controls.render.mock.calls[0][0].props; + + beforeEach(() => { + jest.spyOn(dash, 'getViewerOption').mockImplementation(() => true); + dash.controls = { + destroy: jest.fn(), + render: jest.fn(), + }; + }); + + test('should render react controls with the correct props', () => { + dash.renderUI(); + + expect(getProps(dash)).toMatchObject({ + autoplay: false, + currentTime: expect.any(Number), + isPlaying: expect.any(Boolean), + onAutoplayChange: dash.setAutoplay, + onFullscreenToggle: dash.toggleFullscreen, + onMuteChange: dash.toggleMute, + onPlayPause: dash.togglePlay, + onRateChange: dash.setRate, + onTimeChange: dash.handleTimeupdateFromMediaControls, + onVolumeChange: dash.setVolume, + rate: '1.0', + volume: expect.any(Number), + }); + }); + }); });