@@ -1194,4 +1194,41 @@ QUnit[qunitFn]('sourceset', function(hooks) {
1194
1194
player . src ( youtubeSrc ) ;
1195
1195
1196
1196
} ) ;
1197
+
1198
+ QUnit . test ( 'tech sourceset update sources cache when changingSrc_ is false' , function ( assert ) {
1199
+ const clock = sinon . useFakeTimers ( ) ;
1200
+ const fixture = document . querySelector ( '#qunit-fixture' ) ;
1201
+ const vid = document . createElement ( 'video' ) ;
1202
+
1203
+ fixture . appendChild ( vid ) ;
1204
+
1205
+ const player = videojs ( vid ) ;
1206
+
1207
+ player . src ( sourceOne ) ;
1208
+
1209
+ clock . tick ( 1 ) ;
1210
+
1211
+ // Declaring the spies here avoids listening to the changes that took place when loading the source.
1212
+ const handleTechSourceset_ = sinon . spy ( player , 'handleTechSourceset_' ) ;
1213
+ const techGet_ = sinon . spy ( player , 'techGet_' ) ;
1214
+ const updateSourceCaches_ = sinon . spy ( player , 'updateSourceCaches_' ) ;
1215
+
1216
+ player . tech_ . trigger ( 'sourceset' ) ;
1217
+
1218
+ assert . ok ( handleTechSourceset_ . calledOnce , 'handleTechSourceset_ was called' ) ;
1219
+ assert . ok ( ! techGet_ . called , 'techGet_ was not called' ) ;
1220
+ assert . ok ( updateSourceCaches_ . calledOnce , 'updateSourceCaches_ was called' ) ;
1221
+ assert . equal ( player . cache_ . src , '' , 'player.cache_.src was reset' ) ;
1222
+
1223
+ player . tech_ . trigger ( 'loadstart' ) ;
1224
+
1225
+ assert . ok ( techGet_ . called , 'techGet_ was called' ) ;
1226
+ assert . equal ( updateSourceCaches_ . callCount , 2 , 'updateSourceCaches_ was called twice' ) ;
1227
+
1228
+ handleTechSourceset_ . restore ( ) ;
1229
+ techGet_ . restore ( ) ;
1230
+ updateSourceCaches_ . restore ( ) ;
1231
+ player . dispose ( ) ;
1232
+ clock . restore ( ) ;
1233
+ } ) ;
1197
1234
} ) ;
0 commit comments