Skip to content

Commit

Permalink
Add tests for synthetic stall playing events
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-coward committed Oct 17, 2024
1 parent 606cd6b commit 735ad6a
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion test/unit/test/streaming/streaming.models.VideoModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('VideoModel', () => {
});

describe('setStallState()', () => {
describe('syntheticStallEvents enabled', () => {
describe('syntheticStallEvents enabled', () => {
beforeEach(() => {
settings.update({ streaming: { buffer: { syntheticStallEvents: { enabled: true, ignoreReadyState: false } }}});
videoModel.setConfig({ settings });
Expand All @@ -66,6 +66,32 @@ describe('VideoModel', () => {

videoModel.setStallState('video', true);
});

it('Should emit a playing event on stall end even if not in ready state if ignoring ready state', (done) => {
settings.update({ streaming: { buffer: { syntheticStallEvents: { enabled: true, ignoreReadyState: true } }}});

videoElementMock.readyState = Constants.VIDEO_ELEMENT_READY_STATES.HAVE_NOTHING;

const onPlaying = () => {
videoElementMock.removeEventListener('playing', onPlaying);
done();
}
videoElementMock.addEventListener('playing', onPlaying);

videoModel.setStallState('video', false);
});

it('Should emit a playing event on stall end if video element is in ready state', (done) => {
videoElementMock.readyState = Constants.VIDEO_ELEMENT_READY_STATES.HAVE_FUTURE_DATA;

const onPlaying = () => {
videoElementMock.removeEventListener('playing', onPlaying);
done();
}
videoElementMock.addEventListener('playing', onPlaying);

videoModel.setStallState('video', false);
});
});
});
});

0 comments on commit 735ad6a

Please sign in to comment.