feat: set videoId to '' instead of null on load (#205)

This commit is contained in:
Raymond Zhou
2023-01-20 08:22:18 -08:00
committed by GitHub
parent 5e037a7209
commit 9c4077f32d
2 changed files with 15 additions and 2 deletions

View File

@@ -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 || [],
};

View File

@@ -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({