@@ -48,15 +48,15 @@ describe('cms api', () => {
4848 } ) ;
4949 describe ( 'apiMethods' , ( ) => {
5050 describe ( 'fetchBlockId' , ( ) => {
51- it ( 'should call get with url.blocks' , ( ) => {
52- apiMethods . fetchBlockById ( { blockId, studioEndpointUrl } ) ;
51+ it ( 'should call get with url.blocks' , async ( ) => {
52+ await apiMethods . fetchBlockById ( { blockId, studioEndpointUrl } ) ;
5353 expect ( get ) . toHaveBeenCalledWith ( urls . block ( { blockId, studioEndpointUrl } ) ) ;
5454 } ) ;
5555 } ) ;
5656
5757 describe ( 'fetchByUnitId' , ( ) => {
58- it ( 'should call get with url.blockAncestor' , ( ) => {
59- apiMethods . fetchByUnitId ( { blockId, studioEndpointUrl } ) ;
58+ it ( 'should call get with url.blockAncestor' , async ( ) => {
59+ await apiMethods . fetchByUnitId ( { blockId, studioEndpointUrl } ) ;
6060 expect ( get ) . toHaveBeenCalledWith ( urls . blockAncestor ( { studioEndpointUrl, blockId } ) , { } ) ;
6161 } ) ;
6262
@@ -82,7 +82,7 @@ describe('cms api', () => {
8282 // eslint-disable-next-line no-shadow, @typescript-eslint/no-shadow
8383 const utils = await import ( './utils' ) ;
8484 const getSpy = jest . spyOn ( utils , 'get' ) ;
85- apiMethods . fetchByUnitId ( { blockId, studioEndpointUrl } ) ;
85+ await apiMethods . fetchByUnitId ( { blockId, studioEndpointUrl } ) ;
8686 expect ( getSpy ) . toHaveBeenCalledWith ( urls . blockAncestor ( { studioEndpointUrl, blockId } ) , { } ) ;
8787 } ) ;
8888
@@ -94,22 +94,22 @@ describe('cms api', () => {
9494 // eslint-disable-next-line no-shadow, @typescript-eslint/no-shadow
9595 const utils = await import ( './utils' ) ;
9696 const getSpy = jest . spyOn ( utils , 'get' ) ;
97- apiMethods . fetchByUnitId ( { blockId, studioEndpointUrl } ) ;
97+ await apiMethods . fetchByUnitId ( { blockId, studioEndpointUrl } ) ;
9898 expect ( getSpy ) . toHaveBeenCalledWith ( urls . blockAncestor ( { studioEndpointUrl, blockId } ) , { } ) ;
9999 } ) ;
100100 } ) ;
101101 } ) ;
102102
103103 describe ( 'fetchStudioView' , ( ) => {
104- it ( 'should call get with url.blockStudioView' , ( ) => {
105- apiMethods . fetchStudioView ( { blockId, studioEndpointUrl } ) ;
104+ it ( 'should call get with url.blockStudioView' , async ( ) => {
105+ await apiMethods . fetchStudioView ( { blockId, studioEndpointUrl } ) ;
106106 expect ( get ) . toHaveBeenCalledWith ( urls . blockStudioView ( { studioEndpointUrl, blockId } ) ) ;
107107 } ) ;
108108 } ) ;
109109
110110 describe ( 'fetchCourseImages' , ( ) => {
111- it ( 'should call get with url.courseAssets' , ( ) => {
112- apiMethods . fetchCourseImages ( {
111+ it ( 'should call get with url.courseAssets' , async ( ) => {
112+ await apiMethods . fetchCourseImages ( {
113113 learningContextId, studioEndpointUrl, pageNumber : 0 ,
114114 } ) ;
115115 const params = {
@@ -123,8 +123,8 @@ describe('cms api', () => {
123123 } ) ;
124124 } ) ;
125125 describe ( 'fetchLibraryImages' , ( ) => {
126- it ( 'should call get with urls.libraryAssets for library V2' , ( ) => {
127- apiMethods . fetchLibraryImages ( {
126+ it ( 'should call get with urls.libraryAssets for library V2' , async ( ) => {
127+ await apiMethods . fetchLibraryImages ( {
128128 blockId,
129129 } ) ;
130130 expect ( get ) . toHaveBeenCalledWith (
@@ -134,30 +134,30 @@ describe('cms api', () => {
134134 } ) ;
135135
136136 describe ( 'fetchCourseDetails' , ( ) => {
137- it ( 'should call get with url.courseDetailsUrl' , ( ) => {
138- apiMethods . fetchCourseDetails ( { learningContextId, studioEndpointUrl } ) ;
137+ it ( 'should call get with url.courseDetailsUrl' , async ( ) => {
138+ await apiMethods . fetchCourseDetails ( { learningContextId, studioEndpointUrl } ) ;
139139 expect ( get ) . toHaveBeenCalledWith ( urls . courseDetailsUrl ( { studioEndpointUrl, learningContextId } ) ) ;
140140 } ) ;
141141 } ) ;
142142
143143 describe ( 'fetchVideos' , ( ) => {
144- it ( 'should call get with url.courseVideos' , ( ) => {
145- apiMethods . fetchVideos ( { learningContextId, studioEndpointUrl } ) ;
144+ it ( 'should call get with url.courseVideos' , async ( ) => {
145+ await apiMethods . fetchVideos ( { learningContextId, studioEndpointUrl } ) ;
146146 expect ( get ) . toHaveBeenCalledWith ( urls . courseVideos ( { studioEndpointUrl, learningContextId } ) ) ;
147147 } ) ;
148148 } ) ;
149149
150150 describe ( 'fetchAdvancedSettings' , ( ) => {
151- it ( 'should call get with url.courseAdvanceSettings' , ( ) => {
152- apiMethods . fetchAdvancedSettings ( { learningContextId, studioEndpointUrl } ) ;
151+ it ( 'should call get with url.courseAdvanceSettings' , async ( ) => {
152+ await apiMethods . fetchAdvancedSettings ( { learningContextId, studioEndpointUrl } ) ;
153153 expect ( get ) . toHaveBeenCalledWith ( urls . courseAdvanceSettings ( { studioEndpointUrl, learningContextId } ) ) ;
154154 } ) ;
155155 } ) ;
156156
157157 describe ( 'getHandlerUrl' , ( ) => {
158- it ( 'should call get with url.handlerUrl' , ( ) => {
158+ it ( 'should call get with url.handlerUrl' , async ( ) => {
159159 const handlerName = 'transcript' ;
160- apiMethods . getHandlerUrl ( { studioEndpointUrl, blockId, handlerName } ) ;
160+ await apiMethods . getHandlerUrl ( { studioEndpointUrl, blockId, handlerName } ) ;
161161 expect ( get ) . toHaveBeenCalledWith ( urls . handlerUrl ( { studioEndpointUrl, blockId, handlerName } ) ) ;
162162 } ) ;
163163 } ) ;
@@ -250,8 +250,8 @@ describe('cms api', () => {
250250
251251 describe ( 'saveBlock' , ( ) => {
252252 const content = 'Im baby palo santo ugh celiac fashion axe. La croix lo-fi venmo whatever. Beard man braid migas single-origin coffee forage ramps.' ;
253- it ( 'should call post with urls.block and normalizeContent' , ( ) => {
254- apiMethods . saveBlock ( {
253+ it ( 'should call post with urls.block and normalizeContent' , async ( ) => {
254+ await apiMethods . saveBlock ( {
255255 blockId,
256256 blockType : 'html' ,
257257 content,
@@ -278,8 +278,8 @@ describe('cms api', () => {
278278 const asset = new File ( [ img ] , filename , { type : 'image/jpeg' } ) ;
279279 const mockFormdata = new FormData ( ) ;
280280 mockFormdata . append ( 'file' , asset ) ;
281- it ( 'should call post with urls.courseAssets and imgdata' , ( ) => {
282- apiMethods . uploadAsset ( {
281+ it ( 'should call post with urls.courseAssets and imgdata' , async ( ) => {
282+ await apiMethods . uploadAsset ( {
283283 blockId,
284284 learningContextId,
285285 studioEndpointUrl,
@@ -290,10 +290,10 @@ describe('cms api', () => {
290290 mockFormdata ,
291291 ) ;
292292 } ) ;
293- it ( 'should call post with urls.libraryAssets and imgdata' , ( ) => {
293+ it ( 'should call post with urls.libraryAssets and imgdata' , async ( ) => {
294294 learningContextId = 'lib:demo2uX' ;
295295 mockFormdata . append ( 'content' , asset ) ;
296- apiMethods . uploadAsset ( {
296+ await apiMethods . uploadAsset ( {
297297 blockId,
298298 learningContextId,
299299 studioEndpointUrl,
@@ -307,10 +307,10 @@ describe('cms api', () => {
307307 } ) ;
308308
309309 describe ( 'uploadVideo' , ( ) => {
310- it ( 'should call post with urls.courseVideos and data' , ( ) => {
310+ it ( 'should call post with urls.courseVideos and data' , async ( ) => {
311311 const data = { files : [ { file_name : 'video.mp4' , content_type : 'mp4' } ] } ;
312312
313- apiMethods . uploadVideo ( { data, studioEndpointUrl, learningContextId } ) ;
313+ await apiMethods . uploadVideo ( { data, studioEndpointUrl, learningContextId } ) ;
314314
315315 expect ( urls . courseVideos ) . toHaveBeenCalledWith ( { studioEndpointUrl, learningContextId } ) ;
316316 expect ( post ) . toHaveBeenCalledWith (
@@ -354,10 +354,10 @@ describe('cms api', () => {
354354 describe ( 'uploadThumbnail' , ( ) => {
355355 const thumbnail = 'dAta' ;
356356 const videoId = 'sOmeVIDeoiD' ;
357- it ( 'should call post with urls.thumbnailUpload and thumbnail data' , ( ) => {
357+ it ( 'should call post with urls.thumbnailUpload and thumbnail data' , async ( ) => {
358358 const mockFormdata = new FormData ( ) ;
359359 mockFormdata . append ( 'file' , thumbnail ) ;
360- apiMethods . uploadThumbnail ( {
360+ await apiMethods . uploadThumbnail ( {
361361 studioEndpointUrl,
362362 learningContextId,
363363 videoId,
@@ -376,8 +376,8 @@ describe('cms api', () => {
376376 const youTubeId = 'SOMeyoutUBeid' ;
377377 describe ( 'checkTranscriptsForImport' , ( ) => {
378378 const getJSON = `{"locator":"${ blockId } ","videos":[{"mode":"youtube","video":"${ youTubeId } ","type":"youtube"},{"mode":"edx_video_id","type":"edx_video_id","video":"${ videoId } "}]}` ;
379- it ( 'should call get with url.checkTranscriptsForImport' , ( ) => {
380- apiMethods . checkTranscriptsForImport ( {
379+ it ( 'should call get with url.checkTranscriptsForImport' , async ( ) => {
380+ await apiMethods . checkTranscriptsForImport ( {
381381 studioEndpointUrl,
382382 blockId,
383383 videoId,
@@ -391,8 +391,8 @@ describe('cms api', () => {
391391 } ) ;
392392 describe ( 'importTranscript' , ( ) => {
393393 const getJSON = `{"locator":"${ blockId } ","videos":[{"mode":"youtube","video":"${ youTubeId } ","type":"youtube"}]}` ;
394- it ( 'should call get with url.replaceTranscript' , ( ) => {
395- apiMethods . importTranscript ( { studioEndpointUrl, blockId, youTubeId } ) ;
394+ it ( 'should call get with url.replaceTranscript' , async ( ) => {
395+ await apiMethods . importTranscript ( { studioEndpointUrl, blockId, youTubeId } ) ;
396396 expect ( get ) . toHaveBeenCalledWith ( urls . replaceTranscript ( {
397397 studioEndpointUrl,
398398 parameters : encodeURIComponent ( getJSON ) ,
@@ -401,13 +401,13 @@ describe('cms api', () => {
401401 } ) ;
402402 describe ( 'uploadTranscript' , ( ) => {
403403 const transcript = new Blob ( [ 'dAta' ] ) ;
404- it ( 'should call post with urls.videoTranscripts and transcript data' , ( ) => {
404+ it ( 'should call post with urls.videoTranscripts and transcript data' , async ( ) => {
405405 const mockFormdata = new FormData ( ) ;
406406 mockFormdata . append ( 'file' , transcript ) ;
407407 mockFormdata . append ( 'edx_video_id' , videoId ) ;
408408 mockFormdata . append ( 'language_code' , language ) ;
409409 mockFormdata . append ( 'new_language_code' , language ) ;
410- apiMethods . uploadTranscript ( {
410+ await apiMethods . uploadTranscript ( {
411411 blockId,
412412 studioEndpointUrl,
413413 transcript,
@@ -422,14 +422,14 @@ describe('cms api', () => {
422422 } ) ;
423423 describe ( 'uploadTranscriptV2' , ( ) => {
424424 const transcript = new Blob ( [ 'dAta' ] ) ;
425- it ( 'should call post with urls.uploadTranscriptV2 and transcript data' , ( ) => {
425+ it ( 'should call post with urls.uploadTranscriptV2 and transcript data' , async ( ) => {
426426 const mockFormdata = new FormData ( ) ;
427427 const transcriptHandlerUrl = 'handlerUrl' ;
428428 mockFormdata . append ( 'file' , transcript ) ;
429429 mockFormdata . append ( 'edx_video_id' , videoId ) ;
430430 mockFormdata . append ( 'language_code' , language ) ;
431431 mockFormdata . append ( 'new_language_code' , language ) ;
432- apiMethods . uploadTranscriptV2 ( {
432+ await apiMethods . uploadTranscriptV2 ( {
433433 handlerUrl : transcriptHandlerUrl ,
434434 transcript,
435435 videoId,
@@ -442,9 +442,9 @@ describe('cms api', () => {
442442 } ) ;
443443 } ) ;
444444 describe ( 'transcript delete' , ( ) => {
445- it ( 'should call deleteObject with urls.videoTranscripts and transcript data' , ( ) => {
445+ it ( 'should call deleteObject with urls.videoTranscripts and transcript data' , async ( ) => {
446446 const mockDeleteJSON = { data : { lang : language , edx_video_id : videoId } } ;
447- apiMethods . deleteTranscript ( {
447+ await apiMethods . deleteTranscript ( {
448448 blockId,
449449 studioEndpointUrl,
450450 videoId,
@@ -455,10 +455,10 @@ describe('cms api', () => {
455455 mockDeleteJSON ,
456456 ) ;
457457 } ) ;
458- it ( 'should call deleteObject with urls.transcriptXblockV2 and transcript data' , ( ) => {
458+ it ( 'should call deleteObject with urls.transcriptXblockV2 and transcript data' , async ( ) => {
459459 const mockDeleteJSON = { data : { lang : language , edx_video_id : videoId } } ;
460460 const transcriptHandlerUrl = 'handlerUrl' ;
461- apiMethods . deleteTranscriptV2 ( {
461+ await apiMethods . deleteTranscriptV2 ( {
462462 handlerUrl : transcriptHandlerUrl ,
463463 videoId,
464464 language,
@@ -483,10 +483,10 @@ describe('cms api', () => {
483483 mockJSON ,
484484 ) ;
485485 } ) ;
486- it ( 'should call get with urls.transcriptXblockV2 and transcript data' , ( ) => {
486+ it ( 'should call get with urls.transcriptXblockV2 and transcript data' , async ( ) => {
487487 const mockJSON = { data : { lang : language , edx_video_id : videoId } } ;
488488 const transcriptHandlerUrl = 'handlerUrl' ;
489- apiMethods . getTranscriptV2 ( {
489+ await apiMethods . getTranscriptV2 ( {
490490 handlerUrl : transcriptHandlerUrl ,
491491 videoId,
492492 language,
@@ -672,9 +672,9 @@ describe('cms api', () => {
672672 } ) ;
673673 } ) ;
674674 describe ( 'fetchVideoFeatures' , ( ) => {
675- it ( 'should call get with url.videoFeatures' , ( ) => {
675+ it ( 'should call get with url.videoFeatures' , async ( ) => {
676676 const args = { studioEndpointUrl } ;
677- apiMethods . fetchVideoFeatures ( { ...args } ) ;
677+ await apiMethods . fetchVideoFeatures ( { ...args } ) ;
678678 expect ( get ) . toHaveBeenCalledWith ( urls . videoFeatures ( { ...args } ) ) ;
679679 } ) ;
680680 } ) ;
0 commit comments