Skip to content

Commit

Permalink
chore: test
Browse files Browse the repository at this point in the history
  • Loading branch information
adrums86 committed Oct 17, 2024
1 parent 1d1427e commit 1b46f05
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/vtt-segment-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,10 @@ export default class VTTSegmentLoader extends SegmentLoader {
}

handleData_(simpleSegment, result) {
const isFmp4VttSegment = simpleSegment.type === 'vtt' && result.type === 'text';
// handle segment data for fmp4 encapsulated webvtt
if (simpleSegment.type === 'vtt') {

if (isFmp4VttSegment) {
super.handleData_(simpleSegment, result);
}
}
Expand Down
20 changes: 19 additions & 1 deletion test/vtt-segment-loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ QUnit.module('VTTSegmentLoader', function(hooks) {
assert.equal(mockSegmentInfo.cues[0].endTime, 3, 'startTime is correct value');
});

QUnit.test('parseMp4VttCues_ adds parsed mp4VttCues to the segmentInfo object', function(assert) {
QUnit.test('parseMp4VttCues_ adds parsed mp4VttCues to the segmentInfo object using audioTimestamp', function(assert) {
const mockSegmentInfo = {
mp4VttCues: [{
start: 1,
Expand All @@ -1030,5 +1030,23 @@ QUnit.module('VTTSegmentLoader', function(hooks) {
assert.equal(mockSegmentInfo.cues[0].startTime, 1, 'startTime is correct value');
assert.equal(mockSegmentInfo.cues[0].endTime, 3, 'startTime is correct value');
});

QUnit.test('handleData_ passes fmp4 vtt segment data to parent loader', function(assert) {
const done = assert.async();
const mockSimpleSegment = {
type: 'vtt',
stats: 'fake.stats'
};
const mockResult = {
type: 'text'
};

// mock this function to spy the super handleData call.
loader.earlyAbortWhenNeeded_ = (stats) => {
assert.equal(stats, 'fake.stats', 'expected stats value is passed.');
done();
};
loader.handleData_(mockSimpleSegment, mockResult);
});
});
});

0 comments on commit 1b46f05

Please sign in to comment.