From 9c4077f32d37eb569a5ffae4cae041520a770abd Mon Sep 17 00:00:00 2001 From: Raymond Zhou <56318341+rayzhou-bit@users.noreply.github.com> Date: Fri, 20 Jan 2023 08:22:18 -0800 Subject: [PATCH] feat: set videoId to '' instead of null on load (#205) --- src/editors/data/redux/thunkActions/video.js | 4 ++-- src/editors/data/redux/thunkActions/video.test.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/editors/data/redux/thunkActions/video.js b/src/editors/data/redux/thunkActions/video.js index 4b3d628a3..2a3e037e8 100644 --- a/src/editors/data/redux/thunkActions/video.js +++ b/src/editors/data/redux/thunkActions/video.js @@ -27,7 +27,7 @@ export const loadVideoData = () => (dispatch, getState) => { }); dispatch(actions.video.load({ - videoSource: videoUrl, + videoSource: videoUrl || '', videoId, fallbackVideos, allowVideoDownloads: rawVideoData.download_video, @@ -91,7 +91,7 @@ export const determineVideoSources = ({ [videoUrl, fallbackVideos] = [html5Sources[0], html5Sources.slice(1)]; } return { - videoId: edxVideoId, + videoId: edxVideoId || '', videoUrl: videoUrl || '', fallbackVideos: fallbackVideos || [], }; diff --git a/src/editors/data/redux/thunkActions/video.test.js b/src/editors/data/redux/thunkActions/video.test.js index cb90ecde4..eb28c61a2 100644 --- a/src/editors/data/redux/thunkActions/video.test.js +++ b/src/editors/data/redux/thunkActions/video.test.js @@ -181,6 +181,19 @@ describe('video thunkActions', () => { const youtubeId = 'yOuTuBEiD'; const youtubeUrl = `https://youtu.be/${youtubeId}`; const html5Sources = ['htmLOne', 'hTMlTwo', 'htMLthrEE']; + describe('when edx id, youtube id and source values are null', () => { + it('returns empty strings for ids and an empty array for sources', () => { + expect(thunkActions.determineVideoSources({ + edxVideoId: null, + youtubeId: null, + html5Sources: null, + })).toEqual({ + videoUrl: '', + videoId: '', + fallbackVideos: [], + }); + }); + }); describe('when there is an edx video id, youtube id and html5 sources', () => { it('returns all three with the youtube id wrapped in url', () => { expect(thunkActions.determineVideoSources({