Skip to content

Commit 741d27a

Browse files
author
Kyle Seager
committed
Fixed lint issue
1 parent c551288 commit 741d27a

1 file changed

Lines changed: 42 additions & 20 deletions

File tree

tests/unit/controller/audio-stream-controller.ts

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ describe('AudioStreamController', function () {
457457
info: sinon.spy(),
458458
debug: sinon.spy(),
459459
error: sinon.spy(),
460-
bind: function(name: string) {
460+
bind: function (name: string) {
461461
return {
462462
warn: sinon.spy(),
463463
log: sinon.spy(),
@@ -480,7 +480,7 @@ describe('AudioStreamController', function () {
480480
audioStreamController = new AudioStreamController(
481481
hls,
482482
fragmentTracker as FragmentTracker,
483-
keyLoader as KeyLoader
483+
keyLoader as KeyLoader,
484484
);
485485
(audioStreamController as any).media = media;
486486
(audioStreamController as any).config = hls.config;
@@ -494,14 +494,18 @@ describe('AudioStreamController', function () {
494494
});
495495

496496
it('should return bufferInfoEnd when not switching tracks', function () {
497-
const targetTime = (audioStreamController as any).calculateTargetBufferTime(15.0, 20.0);
497+
const targetTime = (
498+
audioStreamController as any
499+
).calculateTargetBufferTime(15.0, 20.0);
498500
expect(targetTime).to.equal(20.0);
499501
});
500502

501503
it('should return loadPosition when flushing', function () {
502504
(audioStreamController as any).flushing = true;
503505

504-
const targetTime = (audioStreamController as any).calculateTargetBufferTime(15.0, 20.0);
506+
const targetTime = (
507+
audioStreamController as any
508+
).calculateTargetBufferTime(15.0, 20.0);
505509
expect(targetTime).to.equal(15.0);
506510
});
507511

@@ -531,9 +535,13 @@ describe('AudioStreamController', function () {
531535
},
532536
];
533537

534-
sinon.stub(audioStreamController as any, 'getRecentBufferedFrags').returns(mockFragments);
538+
sinon
539+
.stub(audioStreamController as any, 'getRecentBufferedFrags')
540+
.returns(mockFragments);
535541

536-
const targetTime = (audioStreamController as any).calculateTargetBufferTime(15.0, 20.0);
542+
const targetTime = (
543+
audioStreamController as any
544+
).calculateTargetBufferTime(15.0, 20.0);
537545

538546
// Expected: avg processing time = (150ms + 300ms) / 2 = 225ms = 0.225s
539547
// Safety buffer = 0.225 * 1.5 = 0.3375s
@@ -549,9 +557,13 @@ describe('AudioStreamController', function () {
549557
name: 'Test Track',
550558
};
551559

552-
sinon.stub(audioStreamController as any, 'getRecentBufferedFrags').returns([]);
560+
sinon
561+
.stub(audioStreamController as any, 'getRecentBufferedFrags')
562+
.returns([]);
553563

554-
const targetTime = (audioStreamController as any).calculateTargetBufferTime(15.0, 20.0);
564+
const targetTime = (
565+
audioStreamController as any
566+
).calculateTargetBufferTime(15.0, 20.0);
555567
expect(targetTime).to.equal(20.0);
556568
});
557569

@@ -562,7 +574,9 @@ describe('AudioStreamController', function () {
562574
name: 'Test Track',
563575
};
564576

565-
const targetTime = (audioStreamController as any).calculateTargetBufferTime(15.0, 20.0);
577+
const targetTime = (
578+
audioStreamController as any
579+
).calculateTargetBufferTime(15.0, 20.0);
566580
expect(targetTime).to.equal(20.0);
567581
});
568582
});
@@ -582,7 +596,10 @@ describe('AudioStreamController', function () {
582596
};
583597
(audioStreamController as any).fragmentTracker = fragmentTracker;
584598

585-
const result = (audioStreamController as any).getRecentBufferedFrags(10.0, 3);
599+
const result = (audioStreamController as any).getRecentBufferedFrags(
600+
10.0,
601+
3,
602+
);
586603

587604
expect(fragmentTracker.getFragmentsInRange).to.have.been.calledWith(
588605
0,
@@ -599,7 +616,9 @@ describe('AudioStreamController', function () {
599616

600617
describe('calculateAverageProcessingTimeSec', function () {
601618
it('should return 0 for empty fragments array', function () {
602-
const avgTime = (audioStreamController as any).calculateAverageProcessingTimeSec([]);
619+
const avgTime = (
620+
audioStreamController as any
621+
).calculateAverageProcessingTimeSec([]);
603622
expect(avgTime).to.equal(0);
604623
});
605624

@@ -621,7 +640,9 @@ describe('AudioStreamController', function () {
621640
},
622641
];
623642

624-
const avgTime = (audioStreamController as any).calculateAverageProcessingTimeSec(fragments);
643+
const avgTime = (
644+
audioStreamController as any
645+
).calculateAverageProcessingTimeSec(fragments);
625646

626647
// Fragment 1: 100 + 20 + 30 = 150ms
627648
// Fragment 2: 300 + 50 + 50 = 400ms
@@ -641,7 +662,9 @@ describe('AudioStreamController', function () {
641662
{}, // Fragment without stats
642663
];
643664

644-
const avgTime = (audioStreamController as any).calculateAverageProcessingTimeSec(fragments);
665+
const avgTime = (
666+
audioStreamController as any
667+
).calculateAverageProcessingTimeSec(fragments);
645668

646669
// Only first fragment: 200 + 20 + 30 = 250ms, but divided by 2 fragments = 125ms = 0.125s
647670
expect(avgTime).to.equal(0.125);
@@ -650,11 +673,6 @@ describe('AudioStreamController', function () {
650673

651674
describe('integration with track switching', function () {
652675
it('should use safety buffer when switchingTrack.flushBuffer is false', function () {
653-
const trackDetails = {
654-
fragments: [{ start: 0 }],
655-
PTSKnown: true,
656-
};
657-
658676
(audioStreamController as any).switchingTrack = {
659677
flushBuffer: false,
660678
id: 1,
@@ -670,10 +688,14 @@ describe('AudioStreamController', function () {
670688
},
671689
},
672690
];
673-
sinon.stub(audioStreamController as any, 'getRecentBufferedFrags').returns(mockFragments);
691+
sinon
692+
.stub(audioStreamController as any, 'getRecentBufferedFrags')
693+
.returns(mockFragments);
674694

675695
// Call calculateTargetBufferTime directly to test safety buffer integration
676-
const targetTime = (audioStreamController as any).calculateTargetBufferTime(15.0, 20.0);
696+
const targetTime = (
697+
audioStreamController as any
698+
).calculateTargetBufferTime(15.0, 20.0);
677699

678700
// Should apply safety buffer: avg time = 200ms = 0.2s, safety = 0.2 * 1.5 = 0.3s
679701
// Min target time = 10.0 + 0.3 = 10.3s, result = min(20.0, 10.3) = 10.3s

0 commit comments

Comments
 (0)