@@ -6,9 +6,6 @@ import SourceLoader from "./manifest/sourceloader"
66import { ManifestType } from "./models/manifesttypes"
77import { TransferFormat } from "./models/transferformats"
88import getError from "./testutils/geterror"
9- import DebugTool from "./debugger/debugtool"
10-
11- jest . mock ( "./debugger/debugtool" )
129
1310jest . mock ( "./manifest/sourceloader" , ( ) => ( {
1411 default : {
@@ -575,34 +572,6 @@ describe("Media Sources", () => {
575572
576573 expect ( mediaSources . currentSource ( ) ) . toBe ( "http://source2.com" )
577574 } )
578-
579- it ( "fails over correctly after sources have been replaced" , async ( ) => {
580- testMedia . urls = [
581- { url : "http://source1.com" , cdn : "http://cdn1.com" } ,
582- { url : "http://source2.com" , cdn : "http://cdn2.com" } ,
583- ]
584-
585- testMedia . audioDescribed = [
586- { url : "http://audiodescribedsource1.com" , cdn : "http://audiodescribedcdn1.com" } ,
587- { url : "http://audiodescribedsource2.com" , cdn : "http://audiodescribedcdn2.com" } ,
588- ]
589-
590- const mediaSources = MediaSources ( )
591- await mediaSources . init ( testMedia )
592-
593- await mediaSources . failover ( {
594- isBufferingTimeoutError : true ,
595- code : PluginEnums . ERROR_CODES . BUFFERING_TIMEOUT ,
596- message : PluginEnums . ERROR_MESSAGES . BUFFERING_TIMEOUT ,
597- duration : 100 ,
598- currentTime : 94 ,
599- } )
600-
601- await mediaSources . replace ( mediaSources . getAudioDescribedSources ( ) )
602- await mediaSources . replace ( mediaSources . getMainSources ( ) )
603-
604- expect ( mediaSources . currentSource ( ) ) . toBe ( "http://source2.com" )
605- } )
606575 } )
607576
608577 describe ( "Subtitle Sources" , ( ) => {
@@ -828,67 +797,4 @@ describe("Media Sources", () => {
828797 expect ( mediaSources . availableSources ( ) ) . toEqual ( [ ] )
829798 } )
830799 } )
831-
832- describe ( "replace" , ( ) => {
833- beforeEach ( ( ) => {
834- jest . clearAllMocks ( )
835- } )
836-
837- it ( "replaces the media sources" , async ( ) => {
838- const cdn = "http://replacedcdn.com"
839- const url = "http://replacedurl.com/"
840-
841- const mediaSources = MediaSources ( )
842- await mediaSources . init ( testMedia )
843-
844- await mediaSources . replace ( [ { cdn, url } ] )
845-
846- expect ( mediaSources . currentSource ( ) ) . toBe ( url )
847- } )
848-
849- it ( "updates debug output after a replace" , async ( ) => {
850- const cdn = "http://replacedcdn.com"
851- const url = "http://replacedurl.com/"
852-
853- const mediaSources = MediaSources ( )
854- await mediaSources . init ( testMedia )
855-
856- await mediaSources . replace ( [ { cdn, url } ] )
857-
858- expect ( DebugTool . dynamicMetric ) . toHaveBeenCalledWith ( "cdns-available" , [ cdn ] )
859- expect ( DebugTool . dynamicMetric ) . toHaveBeenCalledWith ( "current-url" , url )
860- } )
861-
862- it ( "does not refresh the manifest if not needed" , async ( ) => {
863- const cdn = "http://replacedcdn.com"
864- const url = "http://replacedurl.com/"
865-
866- const mediaSources = MediaSources ( )
867- await mediaSources . init ( testMedia )
868-
869- await mediaSources . replace ( [ { cdn, url } ] )
870- expect ( SourceLoader . load ) . toHaveBeenCalledTimes ( 1 )
871- } )
872-
873- it ( "refreshes the manifest if needed" , async ( ) => {
874- const cdn = "http://replacedcdn.com"
875- const url = "http://replacedurl.com/"
876-
877- jest . mocked ( SourceLoader . load ) . mockResolvedValueOnce ( {
878- time : {
879- manifestType : ManifestType . DYNAMIC ,
880- presentationTimeOffsetInMilliseconds : 1731406718000 ,
881- availabilityStartTimeInMilliseconds : 1731406718000 ,
882- timeShiftBufferDepthInMilliseconds : 0 ,
883- } ,
884- transferFormat : TransferFormat . HLS ,
885- } )
886-
887- const mediaSources = MediaSources ( )
888- await mediaSources . init ( testMedia )
889-
890- await mediaSources . replace ( [ { cdn, url } ] )
891- expect ( SourceLoader . load ) . toHaveBeenCalledTimes ( 2 )
892- } )
893- } )
894800} )
0 commit comments